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

code to generate UART0 Receive Interrupt

Hello,

Can you please take a look at my code and tell me what may be wrong with it and what I need to change it so that it generates an interrupt when the UART0 receives data? I am sending data to my target through a terminal emulator program running on the PC, set at 9600 baud 8-N-1. Each keystroke on the keyboard sends an ASCII character to the 8051. The code should jump to the UART0 ISR, but it never does. Are there any registers that I am not initializing properly?

thanks,
Nick



void main(void)
{
IOCON1=0x01;
P1DIR=0xff;
P1=0xff;


IE=0x90;
IOCON0=40;

U0BR=0xD9;
//set baud rate TO 9600
U0CON=0x10;
//enable UART0, 8-1-N

for(;;) //embedded application never stops running
{
}

}


void UART0 () interrupt 4
{
unsigned int data;
P1 = ~P1;
//toggle the io pin

data = U0BUF;
//read data out of the buffer

}

0