2013-11-26 03:06 AM
Hello,
I have a question just for my culture, I have no real error. I send datas via USART3 at the baudrate31250,USART_HardwareFlowControl_None,USART_WordLength_8b. So one USART message takes 250us to be send.Is the uC blocked during this time, or this action is achieve in parralel ? It can be a lot of time... I use this code to send USART:while
(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
USART_SendData(USART3, data);
2013-11-26 03:59 AM
You can read the reference manual to get a detailed idea how peripherals (and also the UART) work.
And no, the peripheral isn't blocking the core. Only the code example you provided does.2013-11-26 04:32 AM
If you want to read the manual ... have a look at how the DMA and USARTs can work together. For example, you can configure the USART to request DMA transfers when transmitting so, provided you know how many buffered bytes to send, the operation completes automatically without microcontroller help.
Another way is to use an interrupt routine that loads new data into the USART when it is ready. No DMA involved, just one interrupt to load each new data byte. Read up on the USART flags and experiment.2013-11-26 06:07 AM
Ok thank you. Because my USART messages have to be sent with the maximum real time, I have to choose the solution with the minimum delay.
2013-11-26 06:25 AM
Is USART blocks the uC during sending datas?
YES, unless it is interrupt driven
some UART 'implementations' (note the quotes) employ wait loops in the main flow. Erik2013-11-26 07:00 AM
Use a buffer, buffer your output strings, send bytes on TXE interrupt.
If you generate data at a rate faster than the transport method, you'll need to speed up the transport, reduce your data generation, or pick another method. ie SWV2013-11-27 09:21 AM
Is there a way to send datas via USART and, in parallel, continue to process my other tasks ?
I mean, between the change of state of the USART output, the microcontroller can be able to do something else ?(I program a real time system, USART datas have to be sent without delay, and others task have to be executed at the right time).2013-11-27 09:40 AM
Is there a way to send datas via USART and, in parallel, continue to process my other tasks?
Of course there is, it's a peripheral device, and doesn't preclude you doing other things. Clearly if you sit in a loop polling it, then things will block, but that's not how people handle peripheral devices in a real-time system. Use a ring-buffer, shovel your data in that, and service it in a USART interrupt ''task''.2013-11-28 02:21 AM
Ok thanks, now I understand ! I'm gonna try this solution...