cancel
Showing results for 
Search instead for 
Did you mean: 

uart interrupt problem

vinothraj
Associate II
Posted on July 06, 2012 at 16:52

The original post was too long to process during our migration. Please click on the attachment to read the original post.
6 REPLIES 6
Posted on July 06, 2012 at 22:06

You'd need to use UART4_IRQHandler() unless you reworked the vector table.

You can't keep calling USART_ReceiveData(), when RXNE signals/interrupts there is ONE character available.

This is not valid C,  'if(buff== ''abc'')', strcmp() would also need a NUL terminated string.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vinothraj
Associate II
Posted on July 07, 2012 at 07:18

hello clive,

             Thank for your reply.i used 

UART4_IRQHandler() like:

#define USARTx_IRQHANDLER   UART4_IRQHandler            in stm32f4xx_it.c

i can able to get a single character using interrupt.

CODE:

               uint8_t ab;

ab=(USART_ReceiveData(UART4) & 0x7F);

                  if (ab=='a')                   //i get the character from uart interrupt and compare with ' a' character. 

  {

                         //do some thing

}

this coding is properly working...but i need to receive the string  in if loop and do something in that loop.

how i can get the string using uart interrupt.it can or can't working?????????????

any help 

               

 

Posted on July 07, 2012 at 12:41

but i need to receive the string  in if loop and do something in that loop. how i can get the string using uart interrupt.it can or can't working?

You'd need to accumulate characters, and/or use a state machine, and when you have enough characters to perform a specific test do it a that point. What you don't want to do in an interrupt is dwell in a while() loop waiting for other things to happen. Do your work quickly, and in a linear flow, and leave.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on July 09, 2012 at 20:21

''This is not valid C,  'if(buff== ''abc'')'''

Yes, it

is

  valid 'C' - but almost certainly not  what the OP intended!

Posted on July 09, 2012 at 22:04

Valid in that it compiles, Invalid in that it will never* work.

* I could construct an example that might ''work'' with specific compilers or settings, such that the pointers have the same address, but this condition wouldn't come close to the desired function as expressed by the OP.

''not viable'' might have been a better choice of words.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on July 09, 2012 at 22:17

''Valid in that it compiles''

Indeed.

'''not viable' might have been a better choice of words''

Yes.

It is a common beginner's mistake to assume that an absence of build errors means that the code must ''work''...