Page 1 of 1

Use of UART Driver on STM32F3 Disco

Posted: Tue Oct 18, 2016 10:41 pm
by tecnologic
Hi all,

i actually got a strange problem with a quite simple uart implementation.

i start the uart driver with CR3 HDSEL set, for half duplex. Then i dont call any api after start. I only wait for the rxchar callback, the driver is in receive idle state. I want to receive a two byte request an set a signal to the thread. So far so simple.

For the test i receive two bytes 0x7F and 0xCF every 800ms and with 4ms between the two bytes. But the rxchar callback is only called with 0x7f if i stop the mcu right in the callback an read RDR register i see the 0xCf, but the callback gets never called with that value only with the first one.

I am sure i miss something or use the driver wrong, but i have no clue where my error is?

any thoughts on this ?

regards

Tec

Re: Use of UART Driver on STM32F3 Disco

Posted: Wed Oct 19, 2016 8:26 pm
by tecnologic
Ok i investigated a little deeper. seems i am getting framing errors. But when the rxerr callback was called with the error the byte gets lost. So i read the RDR in the Error handler and call the rxchar callback from there when RXNE Bit in ISR was set.

Re: Use of UART Driver on STM32F3 Disco

Posted: Thu Oct 20, 2016 8:14 am
by Giovanni
Hi,

Thanks for the hint.

Giovanni

Re: Use of UART Driver on STM32F3 Disco

Posted: Thu Oct 20, 2016 8:56 am
by tecnologic
No Problem,

why this crap half duplex comunication is getting me framing errors i dont know, but with an other device sending the requests every thing works fine.
So i just leave it to handle the error in rxerror callback by reading RDR if RXNE is set and call the rxchar manually. Even if i cut the pullup resistor i get no false receives by this. Just in case someone else has the same problem.

regards

Tec

Re: Use of UART Driver on STM32F3 Disco

Posted: Thu Oct 20, 2016 9:15 am
by Giovanni
I the past I worked with an half duplex protocol, we got a lot of problems with some types of UARTs, we had to add idle delays when switching direction, maybe this can help.

Giovanni

Re: Use of UART Driver on STM32F3 Disco

Posted: Thu Oct 20, 2016 1:32 pm
by steved
I've got some F0 devices working successfully in a 2-wire environment.
Points I consider are:
1. When sending, have a delay of at least one character time between enabling the transmit buffer and starting to send (this allows the receiver time to recover from any glitches or noise). The ST USARTs can do this automatically if auto-RTS is enabled.
2. Use a bias network on the serial line (not just terminators) to hold it in the idle state when nothing is connected.
3. Allow a reasonable quiet time between messages (usually minimum 10msec at 9600 baud) to allow everything to sort itself out