Posted on May 17, 2011 at 12:38Hi st7, Thanks - yes, I have been through all the examples. Trouble is, they are all one-shot. They work fine, but just do one send/receive, then stop/hang. I think you are referring to example 4 - none of the Tx is triggered from the main code, it all happens automatically from within the IRQ's. Yours, John.
Posted on May 17, 2011 at 12:38Hi, I'm looking at a simple/basic interrupt handling code to handle the USART - not using DMA. So to receive into a buffer, and transmit from a buffer, all under interrupt. Then with the support functions for the main code to be able to start a Tx (give a buffer/data), and read from the Rx buffer. Note - I have code to do this, but my Rx routine is dropping a character (or two) occasionally, so I just wanted to see if anyone has good reliable code to do this, then I can see what I'm missing ? Thanks, John.
> my Rx routine is dropping a character (or two) occasionally very probably a race condition, post your code and I'll take a look at it. (no need to post makefiles or complete app cause I won't run it.)
Posted on May 17, 2011 at 12:38Hi Giovanni, Thanks for the help - I downloaded your RTOS and had a look around. from ports, ARMCM3-STM32F103 stm32_serial.c line 71 if (sr & SR_TXE) { your using TXE: Transmit Data Register Empty the same as the examples from ST. I found that this interrupt is constantly firing after the Tx buffer has been sent, because the Transmit Data Register is empty... so it is disabled at the end of data Tx. I'm looking into using TC (Transmission Complete Interrupt), so it does not need repeatedly enabling/disabling. ---- I see to read from the buffer (queue), you disable interrupts: chIQGet() / chSysLock() and the same for writing to the output buffer (queue): chOQPut() / chSysLock() ---- It looks to me like your code and mine are the same, at least logically - only I use the ST libraries, instead of direct register accessing. How did you test your code ? If I run a loopback build in my STM32 device, and connect hyper-term (from a PC) to it - all works fine. Sent chars are echo'd back. The situation where I get dropped input chars (into the STM32) is when it is sending AT command strings to a GSM module. That module echo's back the characters it receives, probably a lot faster, so there is 2-way traffic on the USART. So I still don't understand why I'm dropping Rx chars. Any other thoughts welcome... John.
Posted on May 17, 2011 at 12:38Hi lanchon, Thanks - I thought of that, and so removed all IRQ enable/disable from all of the receiving side of the USART code. It is never disabled, but still misses chars (they are definately there, the PC see them). If you still want to see the code, let me know - I'll have to tidy it a bit, as I'm trying all sorts... John.
Posted on May 17, 2011 at 12:38I'm trying to get a interrupt when the USART has completed sending a single character. So I'm trying to use TC/TCIE. Is this ONLY for DMA (frames ?), or should it work after a direct call to USART_SendData() ? Thanks, John.
that's not going to eliminate races. I don't really *want* to see your code, I'm just offering help. I'm lazy as hell when it comes to reading other people's code, but if I can understand you code there's a fair chance that I can pinpoint the problem. but please clean up the workarounds or I may get lost in the mess.
Included in the RTOS there is a test suite, the tests output is printed through one of the serial ports (usually I read it using hyper terminal...). The formatted output itself is a test that demonstrate that the circular buffers and the low level driver are working. Running the tests I never experienced missing characters on the STM32. Of course something like this is never tested enough :) I really should include a loopback test at high speed too.
Quote:
The situation where I get dropped input chars (into the STM32) is
when it is sending AT command strings to a GSM module. That module echo's back the characters it receives, probably a lot faster, so there is 2-way traffic on the USART.It is possible that is the GSM module dropping the received characters. What line speed are you using ? are you getting framing/overrun/parity errors from the USART ? regards, Giovanni --- ChibiOS/RT