This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC932 and Keypad interface

Hi, I am trying to interface a 4x4 Matrix keypad to the lpc932. I am using its keypad interrupt function. I am also using the application note AN10184 as guidance for code, but I have modified it for simple testing. Also, I am sure the connections are quite different since I have 4 columns and 4 rows on the keypad. I have seen other projects and they use pull up resistors to keep the columns high...why?
I have tried the keypad, but it does not work. P0 pins are all bidirectional, and high, but when pressing a key from the keypad nothing seems to happen. For what I understand, when pressing a key a determine column and row (conbination of two pins) will go low, and if this is true I will see an output on P2. But nothing happens.
Can anyone guide me on this (hardware, software)? Here is a part of the code.
Thanks.

=========================================
void main(void)
{
//TRIM = 0x30;
init(); // configure ports
brkrst_init(); // configure clock source
P0 = 0xFF;
P2 = 0x00;
P3 = 0x00;
P1 = 0x00;

Debounce_Time();// timer 0
keypad_init(); // initialize the keypad hardware

PCON |= 0x02; // enter PDM

_nop_(); _nop_();
_nop_(); _nop_();

while(1)
{
PCON = 0x01; // enter idle

_nop_(); _nop_();
_nop_(); _nop_();
//}
}
}


void keypad_init (void)
{
// port 0 should be set as bidirectional...check
// port 3 should be set as output (push-pull)
KBMASK = 0xFF; // to generate an interrupt port zero should be not equal to
KBPATN = 0XFF; // the value from KBPATN (0xFF)
//KBCON |= 0x02;
EKBI = 1; // enable keypad interrupt
}

static void loc_column (void)
{
right_key = 1;
switch (key_entered)
{
case 0xEE: key_code = '1'; break; // stop executing
case 0xDE: key_code = '2'; break; // stop executing
case 0xBE: key_code = '3'; break; // stop executing
case 0x7E: key_code = '4'; break; // stop executing
case 0xED: key_code = '5'; break; // stop executing
case 0xDD: key_code = '6'; break; // stop executing
case 0xBD: key_code = '7'; break; // stop executing
case 0x7D: key_code = '8'; break; // stop executing
case 0xEB: key_code = '9'; break; // stop executing
case 0xDB: key_code = '0'; break; // stop executing
case 0xBB: key_code = 'A'; break; // stop executing
case 0x7B: key_code = 'B'; break; // stop executing
case 0xE7: key_code = 'C'; break; // stop executing
case 0xD7: key_code = 'D'; break; // stop executing
case 0xB7: key_code = 'E'; break; // stop executing
case 0x77: key_code = 'F'; break; // stop executing


}
}

void Timer0(void) interrupt 1
{
TR0 = 0; // stop timer
key_entered = P0; // save value of port 0
// if a key was released then...
if (key_entered != 0xFF)
{ KBCON |= 2; // PATN_SEL = 1, has to be equal next KB
// int on P0 =0xFF
loc_column();
if (key_code == '1')
{
P2 = 0x01;
PCON = 0x02;
}
if (key_code == '2')
{
P2 = 0x02;
PCON = 0x02;
}
if (key_code == '3')
{
P2 = 0x03;
PCON = 0x02;
}
if (key_code == '4')
{
P2 = 0x04;
PCON = 0x02;
}
if (key_code == '5')
{
P2 = 0x05;
PCON = 0x02;
}
if (key_code == '6')
{
P2 = 0x06;
PCON = 0x02;
}
if (key_code == '7')
{
P2 = 0x07;
PCON = 0x02;
}
if (key_code == '8')
{
P2 = 0x08;
PCON = 0x02;
}
if (right_key)
{
flag = 1;
}
EKBI = 1;
}

void keypad_isr(void) interrupt 7
{
EKBI = 0;
TR0 = 1;
}

0