RX_interrupt ISR problem

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

cross mob
Anonymous
Not applicable

Hi

   

 

   

I want to read 8byte string using UART module and have written the rx interrupt rotine for same as below but not getting the result

   

#pragma interrupt_handler RX_interrupt

   

void RX_interrupt (void)
{
    char i,j;    
    for (i=0;i<=7;i++)
    {
      j= UART_cGetChar();
        //UART_PutChar(j);
        rx_buff=j;
        if (i==7)
        {
         rx_buff[7]='\0';
         rx_flg=1;
        }
        
    }
    UART_CmdReset();
}

   

 

   

mean while i checked putting  below code in main's while loop i am getting the result ,but i want it interrupt based

   

  j= UART_cGetChar();
       UART_PutChar(j);

   

 

   

please suggets me ,where i am getting wrong

   

 

   

regards

   

Habib

0 Likes
10 Replies
Anonymous
Not applicable

i am using PSoc1 ,cy8c22545 controller

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Habib, can you please post your complete project, so that we all can have a look at all of your settings? To do so, use
Designer->File->Archive Project
and attach the resulting file.

   

I can see at first look two errors:

   

You retrieve a character without checking if there is already one received

   

You have programmed a loop within your interrupt handler which will prevent the system from running.

   

Suggestion: Try to program a "Circular Buffer" to store one character after the other.

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Ok Bob

   

here i am attaching my project

   

in this if i am checking in while loop my receive and transmit working fine,

   

i want it interrupt base ,its not working

   

find the attached project

   

 

   

regards

   

Habib

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

hi

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Some suggestions:

   

You enabled the command buffer in the UART component, this will work against your interrupt handling.

   

You receive an interrupt for every byte received, so change your handler to work on only one byte per interrupt.

   

No loops, no waiting in an interrupt handler!!!

   

Better do not declare a loop-variable as global, make use of local variables where appropiate

   

Declare all global variables that get changed in an interrupt handler as "volatile"

   

 

   

Happy coding

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob

   

Thanks for reply ,i have try  as per your suggetions but still i am not getting the interrupt

   

find the attached changed one project file ,

   

please change the project so it can work fine will test it here

   

 

   

regards

   

Habib

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Here it is...

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob

   

Thank you very much ,now its working fine ,

   

if any one facing same problem they can use the above attached project by Bob

   

 

   

Regards

   

Habib

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Glad that I could help you. What is the intention you would use your PSoC1 for?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi

   

we are having stock and our old designs also on same device ,so

0 Likes