UART INTERRUPTS

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 hi...

   

 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*/--------------------------------------

   

   

for(;;)            

   

{

   

   // isr_1_Enable();

   

    if(univ==1)

   

{

   

univ=0;

   

/* I WOULD LIKE TO DO MY TASK HERE */

   

}

   

}

   

 

   

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

   

   

CY_ISR(isr_1_Interrupt)

   

{

   

    /*  Place your Interrupt code here. */

   

    /* `#START isr_1_Interrupt` */

   

/* Check the UART status */

   

 /* Check the UART status */

   

 

   

univ=1;

   

isr_1_Disable();

   

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

   

for(i=0;i<12;)

   

 {

   

       ch = UART_1_GetChar();

   

 //      /* If byte received */

   

  if(ch > 0)

   

    {

   

    text=ch;

   

    i++;         

   

    }

   

}

   

/* 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_FAMILY_USED == CYDEV_CHIP_FAMILY_PSOC3)

   

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

   

            isr_1_ISR_PATCH();

   

        #endif

   

    #endif

   

}

   

 

   

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 goes....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 file...you can go through it.

0 Likes
1 Solution
Anonymous
Not applicable

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 

   

or 

   

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.

View solution in original post

0 Likes
2 Replies