Use of UART Driver on STM32F3 Disco

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
tecnologic
Posts: 124
Joined: Tue Jan 10, 2012 8:42 am
Has thanked: 21 times
Been thanked: 5 times

Use of UART Driver on STM32F3 Disco

Post 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
tecnologic
Posts: 124
Joined: Tue Jan 10, 2012 8:42 am
Has thanked: 21 times
Been thanked: 5 times

Re: Use of UART Driver on STM32F3 Disco

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Use of UART Driver on STM32F3 Disco

Post by Giovanni »

Hi,

Thanks for the hint.

Giovanni
tecnologic
Posts: 124
Joined: Tue Jan 10, 2012 8:42 am
Has thanked: 21 times
Been thanked: 5 times

Re: Use of UART Driver on STM32F3 Disco

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Use of UART Driver on STM32F3 Disco

Post 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
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: Use of UART Driver on STM32F3 Disco

Post 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
Post Reply