You are here

RX_interrupt ISR problem | Cypress Semiconductor

RX_interrupt ISR problem

Summary: 10 Replies, Latest post by Habib_EPI on 14 Dec 2015 10:24 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
Habib_EPI's picture
User
14 posts

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[i]=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

Habib_EPI's picture
User
14 posts

i am using PSoc1 ,cy8c22545 controller

user_1377889's picture
User
9581 posts

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

 

Habib_EPI's picture
User
14 posts

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

Attachments: 
Habib_EPI's picture
User
14 posts

hi

user_1377889's picture
User
9581 posts

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

Habib_EPI's picture
User
14 posts

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

 

user_1377889's picture
User
9581 posts

Here it is...

 

Bob

Habib_EPI's picture
User
14 posts

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

user_1377889's picture
User
9581 posts

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

 

Bob

Habib_EPI's picture
User
14 posts

Hi

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

Log in to post new comments.