You are here

UART INTERRUPTS | Cypress Semiconductor


Summary: 2 Replies, Latest post by Bob Marlowe on 26 Oct 2012 07:46 AM PDT
Verified Answers: 2
Last post
Log in to post new comments.
sivananda's picture
59 posts


 today i tried to read a 12 byte data with an UART component of Psoc3, for this i kept the settings of UART in RX mode as 

9600 Bits per second (kept with reference to my RFID reader, which is the source for 12 byte data).

Data bits:8, 

Parity type:None,

Stop bits:1

Flow control: None,

Clock Selection :Internal clock,

RX Address configuration: 

                Adress mode: None,

Advanced features:

               Break signal bits: None,

               Enable 2 out of 3 voting per bit, and disabled CRC outputs.

RX Buffer sizes:12 bytes,

 Oversampling rate: 8X

and i have chosen an isr_1 component...

The basic problem what i am facing is, i have written an ISR in such a way that whenever my RFID reader (whose TX-OUT pin connected as RX pin of UART) detects the data, the control will transfer to ISR from main program and remains in ISR till it completes the reading of 12 bytes of data......

when it completes the reading of 12 bytes of data..the control is expected to return to main program..........till now everything is fine.....

but, when the control comes back to main program, it is expected to remain in the main program  till  the next interrupt occurs..... but, eventhough the control is properly coming back to main program, it is immediatly swithing over to ISR and remains there....

if i disable the ISR interupt, when my ISR routine is executing....after completion of ISR execution control coming back to main program and remains there...but it is not accepting the further interrupts...(as I disabled it).

If i re-enable the interrupt in my main program, the control is not remaining in main program, it is moving to ISR and stuck at one point as commented in the below code......


--------------------/* This is the part of main program which i am having problem*/--------------------------------------



   // isr_1_Enable();








-----------------------/* This is my ISR */-----------------------------------------------------------------------------------------------



    /*  Place your Interrupt code here. */

    /* `#START isr_1_Interrupt` */

/* Check the UART status */

 /* Check the UART status */




/*---- This is where my control stuck when i uncomment    // isr_1_Enable();     in main program. ----*/



       ch = UART_1_GetChar();

 //      /* If byte received */

  if(ch > 0)






/* Finally 'text' contains my received data, so that i can use it for further analysis */


/* `#END` */


    /* PSoC3 ES1, ES2 RTC ISR PATCH  */ 


        #if((CYDEV_CHIP_REVISION_USED <= CYDEV_CHIP_REVISION_3A_ES2) && (isr_1__ES2_PATCH ))      






Here i am beleiving that, once my RFID reader receives the 12 byte data, interrupt become enabled and the control moves in to ISR...whenever, it completes the execution of ISR it moves back to main program....but still the interrupt (which became active due to previous read of RFID data) is in active state, therefore it is immediately moving to ISR without staing in the main program....because of not having 12 byte data second time it remains stucked at that poit....

now, can any one help me how to make my code, to remain the control in the main program itself (when it comes back from ISR) untill the next interrupt comes..


NOTE: Here iam attaching a ZIP can go through it.

user_460349's picture
1362 posts

1. It is not a proper use of UART ISR to wait for all bytes. The time spend n the ISR should be as short as possible.

2. It would be better to have the ISR save the received data in a circular buffer and check if receive 12 bytes in the main to process to message 


3. In the ISR check for number of bytes received in a linear buffer and perform the operation (if it is not too long). or general a simulate another lower priority interrupt to process the packet.


user_1377889's picture
9273 posts

Two things in your UART are working against each other: there is an INTERNAL(!!) interrupt enabled when the Rx buffer is greater than 4 bytes which is the case with your settings. In this (internal) interrupt the received byte is red and put into a buffer. Now you are thinking, you will receive an interrupt when 12 bytes are received which is not the case, when you hook into the internal int, you'll get control each time a char is received.

The best way out of this is, al Lleung already has suggested to write a circular buffer where you put your chars in (by interrupt) and check in the main-loop for the number of chars.

The same can be accomplished with the internal buffer (you should use more than 12 bytes!!) and check with the API if there are 12 Bytes already received in the main-loop.



Log in to post new comments.