Page 1 of 2
LK202-25 Keypad read over i2c
Posted: Mon Feb 28, 2005 4:03 pm
by fitzi
Hi,
i have a peck of trouble to get the correct Data over i2c which i read from keypad at LK202-25.
I atteched a 3x4 matrix Keypad to LK202-25. I tested the keypad with the Display Tuner and all works fine. After the first test was ok. I tried to writing and reading to the LK202-25 over i2c.
The follow settings are made before i test the i2c functionality:
1. i2c LK202-25 basic address was set to 0x50
2. auto transmit key presses was set to off so that a keypress would be put to the internal key buffer. (works fine over rs232 and poll mode)
After, all settings was made i wrote a character to the module and thereafter i sent a command (backlight off) to the module. All this works fine. But now to my problem the read process of the keypad over i2c.
I tried to read the data of a key press over i2c. Also i sent i2c_read(...) to address 0x51 and my i2c master
Posted: Tue Mar 01, 2005 10:45 am
by Tom
Hi fitzi,
Thanks for posting at the forums.
Please refer to section 4.3 of the manual found at
https://www.matrixorbital.com/files/LK202-25.pdf for a better explanation of the occurances.
If you have any further questions, please feel free to ask.
Best Regards,
Posted: Tue Mar 01, 2005 11:30 am
by fitzi
the problem is:
I press different Buttons at the keypad and get at determined keys the same data back from module.
see above
////key 2 pressed
//data = 0x21
////key 3 pressed
//data = 0x21 //it is the same as key 2
a push to key 2 or key 3 deliver the same data (I can not differ in my program, which key was pressed)
i hope it is clearer now
greeting
Michael
Posted: Tue Mar 01, 2005 11:50 am
by Miles
What set of commands are you sending when you poll the keypad??

Posted: Wed Mar 02, 2005 8:28 am
by fitzi
My test programm has follow operational sequence.
snippets of my programm
Code: Select all
#define LK202_I2CADDR 0x50
//init
i2c_init();
//set AutoTransmitKey to off
char cmd[2] = {0xFE, 0x4F};
//generate start condition, send data, generate stop condition
i2c_write(LK202_I2CADDR, cmd, 2);
//Data buffer
char b[8];
//read 100 times
for(int i=0; i<100; i++) {
i2c_read(LK202_I2CADDR | 0x01, b, 1);
printf("Data read from %X: %X", LK202_I2CADDR | 0x01, b[0] )
Sleep(1500);
}//endfor
best regards
Michael
Posted: Wed Mar 02, 2005 10:20 am
by Tom
Micheal,
Can I see the code where you poll the keypad?
Posted: Wed Mar 02, 2005 12:02 pm
by fitzi
#define LK202_I2CADDR 0x50
//init_i2c..
//AutoTransmitKey off..
{//loop
==============================
//My Poll command
char cmd[] = {0xFE, 0x26};
i2c_write(LK202_I2CADDR, cmd, 2);
===========================
..
..
//Read Data
//print Data
}
Best Regards
Michael
PS: It's non differentiated with or without polling command
Posted: Mon Mar 07, 2005 3:35 pm
by Tom
What is the purpose of Sleep(1500); - is this just for delay? Make sure that it does not put the micro to sleep and put the i2c hardware in some mode that would need restart/reset before you can use it again.
Posted: Mon Mar 07, 2005 4:33 pm
by Tom
Can you also try adding in the code the auto repeat code off. The code is [254][96] or [0xFE][60] .
Hopefully this works for you.
Best Regards,
Posted: Sat Mar 12, 2005 3:18 pm
by fitzi
the Speep(1500); command is only for delaying and does not disturb i2c communication.
I added also the "auto repeat off" [0xfe] [0x60] command to my code. But i get the same results than before.
greeting
Michael
Posted: Mon Mar 14, 2005 3:53 pm
by Tom
What debounce time are you using?
Posted: Sat Mar 19, 2005 6:18 pm
by fitzi
Hi,
the debounce time is set to "20". I set this value at Display Tuner.
This debounce time works fine if the keypad is polled over RS232 within the Display Tuner application.
At i2c mode i get the same results than before.
Best Regards
Michael
Posted: Sat Mar 19, 2005 6:40 pm
by Miles
Are you having any other troubles communicating via the I2C protocol?
Posted: Fri Mar 25, 2005 2:33 pm
by fitzi
the only thing that does not work is reading from the keypad over i2c.
My i2c Interface works fine with other devices, such as the Philips PCF8574AP (i2c I/O Expander). With this chip it is possible to read data from porst and write data to porsts.
greeting
Michael
Posted: Sat Apr 02, 2005 5:20 am
by fitzi
Do you have any other suggestions, how to get the "keypad read" over i2c to run.
Best Regards