-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interrupts on UART2 (Serial console) on Nucleo-F401 #2119
Comments
I found differences between old and new library. I read docs and think that should be UART_IT_TC. If there no data to transmit then buffer is empty all the time and ISR is called constantly. Its useless. |
Hi hesolium - thanks for highlighting this issue! Actually both interrupts make sense and I think that we could end up with both being enabled. It's good to know when there is room in the buffer to send next byte without waiting further (speed up transmission). But it also makes sense to know when the transmission is complete (I've been discussing that point here: #1801 but we could not find an agreement yet on how to solve this in mbed, I think an API change might be needed). All in all, as you can read in previous link, the trend in MBED is so far to rather try to send data as fast as possible, so we will keep UART_IT_TXE usage for now. . It's good to know when there is room in the buffer to send next byte without waiting further (speed up transmission). But it also makes sense to know when the transmission is complete (I've been discussing that point here: #1801 but we could not find an agreement yet on how to solve this in mbed, I think an API change might be needed). All in all, as you can read in previous link, the trend in MBED is so far to rather try to send data as fast as possible, so we will keep UART_IT_TXE usage for now. . But there is indeed a problem in the library (in F4 serial_api.c) - if we enable the TXE interrupt, then we need to clear the flag as well. This is not done now, so I guess this is the reason for the bug you see. I'll verify this asap and keep you posted. |
Hi again - |
@LMSTM:"It's good to know when there is room in the buffer to send next byte without waiting further (speed up transmission). " You are right, but on the other hand, there is a large overhead on the CPU, because after the transmission of each character, UART fire interrupt that must be serviced. If only EOT (and empty buffer) is signaled then we can service interrupt only once per buffer length block character (16/32 bytes). And, additionaly, we need not enable/disable UARTs interrupts. I setup UART interrupts only once (in Serial initialization routine). |
@LMSTM:"All in all, as you can read in previous link, the trend in MBED is so far to rather try to send data as fast as possible" Maybe API should be extended. I see (in the source code of serial_api.c) that using DMA for transmit/receive is possible. I think it will be better direction to develop Serial class for speed-up transfers. |
Serial API provides 2 methods - one character (
Be more specific? |
@hesolium fully agree with you. |
Reported in Issue ARMmbed#2119 There was some inconsistency in serial interrupt handling accross STM32 serial_api.c implementation. In case application wants to be notified of Tx interrupt, it is mainly interested in transmission complete information, which is the _TC interrupt. The _TXE (Transmit Data REgister Empty) is used only within driver in case SERIAL_ASYNCH is being supported to make the transmission more efficient.
@0xc0170, @LMESTM :"Be more specific?" You (and LMESTM) write about the performance of async API. In this particular case (change to TXE flags) causes more complicated code. With the previous version of the library (TC flag) it was enough to setup interrupts (at program start) and initiate transmission on each blok of data. For me, more important than performance is the simplicity (and elegance:) of the program. |
I have old program running on Nucleo-F401 and Nucleo-L152. All communication with the computer is performed through the serial (UART2) using interrupts. For transmit I use simple ISR:
I have a problem with the latest (MBED-DEV) library on Nucleo-F401 (on L152 is OK).
After execution command: console.attach(this, &Console::writeService, Serial::TxIrq);
the application runs very slowly (100x). I took advantage of gdb and I noticed that the interrupt handler (uart_irq in module serial_api.c) is executed very often. Neither the application nor the computer does not send any characters. It seems that this low level ISR takes 99% CPU power for no reason.
The text was updated successfully, but these errors were encountered: