2017-09-18 07:39 AM
Hi.
Now I'm struggling with receiving data by USART.
Currently, I have one USART receive interrupt. and once if there is interrupted by RX, then the data saved into the queue.
I guess but I'm not sure, but while() is too fast. So I can't get the data what I want.
for example, If PC's USART terminal send data with 0x11 0x22 0x33 0x44.. to eval kit. then procedure with delay() in while() is working as well.
But If I remove that delay() then, I can't get data of all (0x11~0x44).
Do I have to add the delay function for receiving the USART data for safely?
What is the fairly common way to process UART frame packet?
One more thing.
USART3_IRQHandler just one activated never after.
void USART3_IRQHandler(void) //RX
{ if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { char rx = USART_ReceiveData(USART3); /*GetCharUSART1();*/ Uart3_EnQueue(rx); USART_ClearITPendingBit(USART3, USART_IT_RXNE); }}Did I someting miss?
2017-09-19 08:59 AM
I've already tried to find some example. But I can't find it. and there is no answer what if I am doing correctly, I don't need delay().
2017-09-19 10:46 AM
Here is an old program from me. It is not exactly what you want but at least it works.
2017-09-19 05:31 PM
Well it is going to take milliseconds for the data to transit, if you expect it to appear instantaneously you will be disappointed. The code will need to iterate to catch and display data.
Not everything comes with examples, some things require a conceptual understanding of the CPU and peripherals, and this doesn't need to be STM32 specific.
The STM32 USART have a single holding buffer for each of the receive and transmit paths, data gets serialized, and each byte received will get a discrete interrupt some micro-second or milli-second separated depending on baud rate. A processor running at MHz is going to iterate potentially thousands of times.