user1175889
user1175889

Reputation: 131

Setting up UART interrupt to trigger when character is received

i am trying to setup an UART interrupt to trigger when a character is entered on the UART screen. The thing is the way i have set it up it seems that the interrupt triggers when transmitting and receiving. I have read the data sheet and it doesnt really say if it can be done and how. Its just says that a interrupt for serial port is avaiable. This is how i have set up the uart

S0CON   =   0x50;      
PCON    |=  0x80;       /* Double Baud rate */
ADCON0  |=  0x80;       /* Use baudrate generator */
S0RELL  =   0xCC;       /* Baudrate = 9614 Baud @ 16Mhz */
S0RELH  =   0x03;
TI0     =   1;                /* Ready to transmit */
ES0 =1;

Does anyone possibly have any idea how this can be accomplished?? I am using Keil compiler and the Infineon C509 Datasheet **link fixed

Thank you

Upvotes: 0

Views: 2582

Answers (1)

David Duncan
David Duncan

Reputation: 1215

Unfortunately, it doesn't look like you'll be able to do what you want cleanly. Taking a look at the user manual--the data sheet is typically insufficient for this type of problem--check out Figure 7.4. The send and receive interrupt flags set by hardware for channel 0, TI0 and RI0, both trigger the default serial communication interrupt, and it doesn't appear that either can be disabled.

There might be other options, but I'd consider one of the following:

  • Polling (vs. using any interrupts for the UART)
  • Use the interrupt as you have it working, but check first thing in your serial comms interrupt that RI0 is set and if it's not, exit immediately. (Just make sure there's not any kind of timing problem with respect to this and clearing the receive flag to make sure you don't have any potential for dropping a byte.)

Link to C509-L user manual (not sure how long it'll persist): Infineon product site

Upvotes: 1

Related Questions