hello frens,
i written code for UART0, where ISR execute when data received from serial port.
void received(void) __irq { unsigned char i; i = U0RBR; UART0_SendByte(i+1); }
but it only execute only one time. please help me to solve this problem.
regards, pankaj Jain
dear fren, thanks for reply, i am new be.
sorry for above short message.
i give code where i use LCD + UART0 Programming,LCD program is working fine.
I am using LPC2148. i able to receive data from polling method but when i use interrupt it execute only one time.
Please help me to solve this problem.
#include <lpc214x.h> #define EN_HI() IO0SET = (1<<18) #define EN_LO() IO0CLR = (1<<18) #define CMD() IO0CLR = (1<<16) #define DATA() IO0SET = (1<<16) #define WRITE() IO0CLR = (1<<17) #define READ() IO0SET = (1<<17) #define LCD_PORT IO0PIN #define SHIFT_HI 15 #define SHIFT_LO 19 #define Fosc 12000000 #define Fcclk (Fosc * 5) #define Fcco (Fcclk * 4) #define Fpclk (Fcclk / 4) * 1 #define UART_BPS 9600 //Set Baud Rate here void Serint(void) __irq; unsigned char str1[] = " SAPCON Instrumets Pvt. Ltd., Indore"; unsigned char str2[] = " Pankaj Kumar Jain R & D "; void DELAY(unsigned char data2) { unsigned int j; for(;data2>0;data2--) for(j=0;j<60000;j++); } const unsigned char SEND_STRING[] = "Nex Robotics PVT LTD\nARM7 LPC214x Development Board\nCommunication Test\nSend any character to continue\n"; const unsigned char SEND_STRING1[] = "Test Passed\n"; void Init_UART0(void) //This function setups UART0 { unsigned int Baud16; U0LCR = 0x83; // DLAB = 1 Baud16 = (Fpclk / 16) / UART_BPS; U0DLM = Baud16 / 256; U0DLL = Baud16 % 256; U0LCR = 0x03; } void UART0_SendByte(unsigned char data) //A function to send a byte on UART0 { U0THR = data; while( (U0LSR&0x40)==0 ); } void UART0_SendStr(const unsigned char *str) //A function to send a string on UART0 { while(1) { if( *str == '\0' ) break; UART0_SendByte(*str++); } } void WRITE_CMD(unsigned char data) { EN_LO(); CMD(); WRITE(); IO0PIN&=0xFF87FFFF; IO0PIN|=(data & 0xF0) << SHIFT_HI; EN_HI(); EN_LO(); IO0PIN&=0xFF87FFFF; IO0PIN|=(data & 0x0F ) << SHIFT_LO; EN_HI(); EN_LO(); DELAY(1); } void WRITE_DATA(unsigned char data) { EN_LO(); DATA(); WRITE(); IO0PIN&=0xFF87FFFF; IO0PIN|=(data & 0xF0) << SHIFT_HI; EN_HI(); EN_LO(); IO0PIN&=0xFF87FFFF; IO0PIN|=((data & 0x0F) << SHIFT_LO); EN_HI(); EN_LO(); DELAY(1); } void Init_LCD(void) { WRITE_CMD(0x20); WRITE_CMD(0x28); WRITE_CMD(0x0C); WRITE_CMD(0x06); } void INIT_PORT(void) { PINSEL0 = 0x00000005 ; PINSEL1 = 0x00000000 ; IO0DIR = 0x007F0000 ; PINSEL2 = 0x00000000 ; IO1DIR = 0x00000000 ; } void LCD_STR(unsigned char *data1) { while(*data1){ WRITE_DATA(*data1); data1++;} } int main(void) { VICIntEnable = 0x40; // Enable UART0 Interrupt VICIntSelect = 0x00; // Set UART0 is IRQ all interrupt's are IRQ categary VICVectCntl0 = 0x26; // Set SLOT0 for UART Interrupt // i.e. set highest priority in IRQ VICVectAddr0 = (unsigned int)Serint;//0x1E8; // Set interrupt vector U0IER = 0x01; // Enable Transmit interrupt and // Recieve line status interrupts INIT_PORT(); Init_LCD(); Init_UART0(); WRITE_CMD(0x01); WRITE_CMD(0x80); LCD_STR(&str2[0]); WRITE_CMD(0xC0); LCD_STR(&str1[0]); DELAY(20); UART0_SendStr("hi dear"); while(1) { WRITE_CMD(0x18); DELAY(150); } } void Serint(void) __irq { unsigned char i; i = U0RBR; UART0_SendStr("\n\n\n"); UART0_SendByte(i+1); }
Did you look at any sample code yet? Or checked the user manual for the processor about how to acknowledge interrupts? You still haven't tried to acknowledge the interrupt before returning from the interrupt handler.
Maybe you should download the code package available for your specific processor from NXP and really spend some time looking at that code. Yes, the quality isn't so good. But it does contain the magic lines you seem to have forgotten.
How much of the documentation available at: ics.nxp.com/.../ have you looked at?