Search This Blog

Sunday, July 29, 2018

ChibiTerm - The abc of async serial

Projects / ChibiTerm  Original post date: 03/11/2016

I port FIFO code to the STM32F0 and got interrupt serial to work. The firmware echoes character typed on the PC back to the PC.


There is an autobaud feature on the serial port. It uses the timing of the Rx character to set the baud rate.

Reference manual - serial port control register bit assignment
That text description wasn't too obvious, but when I looked at the logic analyzer timing and here is what I figure out.

Async serial timing (from logic analyzer)
ABRMOD[00]: In order to measure the start bit timing, bit 1 (LSB) has to be '1'. Otherwise the USART is measuring the wrong bit timing.


ABRMOD[01]: The LSB has to be '01', so that it can measure the falling edge from the falling edge between Start Bit and Bit 1 to the falling edge between bit 1 to bit 2.

The character 0x0d is one of the characters that satisfies both of these cases. on the other hand fails both cases. Guess which one I had been trying?

I have to figure out how to implement the autobaud so that it works reliably in a system.

  • Can't leave it on at all times as it would try to recalculate the timing based on received characters that might not have the expected bit pattern.
  • Enabling it at the beginning might catches power on/connection glitches of the external device.
  • I have no choice of the incoming characters from the embedded system, so for a sanity check, probably have to look at the detected rate to see if it matches one of the known ones.
  • Probably trigger this on frame error.

I'll leave it off for now as it is an optional feature and can get very complicated quickly.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.