Hi friends,
I am a newbie. I just have started my ARM career with NXP's LPC2148 kit. I am doing simple project of interfacing 4*4 matrix keypad with LPC2148 module. The progam is that after pressing a key, the key will be displayed in the flash magic terminal window using UART serial communication. So, after uploaded the program to the kit, terminal shows the message "matrix keypad Press the key' as mentioned in the program. But when i press the key, the terminal doesn't show the pressed key. I didn't get any error in compiling also. My program is
#define CR 0x0D#include <LPC21xx.H>#define SW 16unsigned char putchar (char ch);unsigned char M,N,Row_Data, Col_Data;unsigned char Msg[4][4] = { 'C','D','E','F', '8','9','A','B', '4','5','6','7', '0','1','2','3' };void init_serial (void);void Delay_Key(void);void KeyScan(void);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Code Begins Here >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int main(void){ char *Ptr = "Matrix Keypad \n Press the key!! \n";
VPBDIV = 0x02; //Divide Pclk by two init_serial();while (*Ptr!=0x00) { putchar(*Ptr); Ptr++; }while(1) { Delay_Key(); KeyScan(); /* Call KeyScan to Scan Row & Column */ Delay_Key(); if (Row_Data < 4 && Col_Data < 4) { Delay_Key(); putchar(Msg[Row_Data][Col_Data]); //Echo terminal Delay_Key(); }}
}//<<<<<<<<<<<<<<<<<<<<<<<<< Serial Initialization >>>>>>>>>>>>>>>>>>>>>>>>>>>>
void init_serial (void) /* Initialize Serial Interface */{ PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */ U0LCR = 0x00000083; /* 8 bits, no Parity, 1 Stop bit */ U0DLL = 0x000000C3; /* 9600 Baud Rate @ 30MHz VPB Clock */ U0LCR = 0x00000003; /* DLAB = 0 */}
//<<<<<<<<<<<<<<<<<<<<<<<<<<< Putchar Function >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
unsigned char putchar (char ch) /* Write character to Serial Port */{
if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; /* output CR */ } while (!(U0LSR & 0x20)); return (U0THR = ch);}void Delay_Key(void){ unsigned int i,j; for(i=0;i<350;i++) for(j=0;j<1234;j++);}
void KeyScan(){
PINSEL1 = 0x00000000; Delay_Key(); IODIR0 = (0x0F << SW); // Configuring Rows as Input && Colum as OutPut (P0.16 - P0.23) IO0PIN = (0xF0 << SW); // Push Column Values to LOW so as to get ROW value
while (((IOPIN0>>SW)&0x00F0) == 0xF0); M = IOPIN0 >> SW;
if (M == 0xE0) { Row_Data = 0; } else if (M == 0xD0) { Row_Data = 1; } else if (M == 0xB0) { Row_Data = 2; } else if (M == 0x70) { Row_Data = 3; } else Row_Data = 4;
Delay_Key(); Delay_Key(); /*^^^^^^^^^^^^^^^^^^^ Scanning of Column ^^^^^^^^^^^^^^^^^^^^^^^^^*/ IOPIN0 = 0x0F << SW; IODIR0 = (0xF0 << SW); // Configure Column as Input and Rows as OutPut (P0.16 - P0.23) IOPIN0 = (0x0F << SW); // Push LOW to Rows to get the Column value of Key Press
while (((IOPIN0>>SW)&0x000F) == 0x0F);
N = (IOPIN0 >> SW);
if (N == 0x0E) { Col_Data = 0; } else if (N == 0x0D) { Col_Data = 1; } else if (N == 0x0B) { Col_Data = 2; } else if (N == 0x07) { Col_Data = 3; } else Col_Data = 4;
Delay_Key(); IOPIN0 = 0xF0 << SW; Delay_Key(); }
So kindly help me get rid off this problem
CKT_lover said: I just have started my ARM career with NXP's LPC2148
That's a very old part to be starting out with in 2019!
https://community.arm.com/developer/tools-software/tools/f/keil-forum/43684/lpc2148-timer0-not-working-as-expected/158928#158928
CKT_lover said:I am doing simple project of interfacing 4*4 matrix keypad with LPC2148 module
I would suggest that there's a few more basic steps you need to master before that:
https://www.avrfreaks.net/comment/1138166#comment-1138166
https://www.avrfreaks.net/comment/2079906#comment-2079906
Has your other thread been resolved yet? Is do, don't forget to verify the answer(s):
CKT_lover said:the flash magic terminal window
Does FlashMagic have a terminal window?
http://www.flashmagictool.com/