Welcome

Implementation

I decided on trying to push all this logic into an ATTiny2313, which resulted in a deliciously small device, which connects to one of the FT232 breakout boards I have:

The schematic of the board is as simple as the board is. The hardware uart of the ATTiny2313 is connected to the FT232, which also provides power to the ATTiny2313. The only components remaining is a decoupling capacitor and a crystal. Officially, you can't run the ATTiny without capacitors on the crystal pins, and the 20MHz-operation at a Vcc of 3.3V is out of spec too, but I never had problems with that. The CTS-line implements handshaking, by the way: it tells the PC to wait with sending more bits until the device has sent the previous ones.

The software source is written in C. When I started writing it, I wanted it to be nice and readable, with the subfunctions nicely separated and every function interrupt-driven. This approach made for some really nice code... which didn't work at higher baudrates, unfortunately. The source as it is now is a bit of a mess, with shared global variables and idle-waiting and whatnot, but at least it is quick enough to actually work.

A bit of explanation: The software makes heavy use of the 16-bit timer. Timer 1 runs continuously on the main clock, and this 16-bit timer is software-extended to 32 bits, so the firmware can even detect baudrates as low as 110 baud. The input capture functionality of this timer is used to measure how long the received signal is low. Its interrupt is also used to kick off the software UART routine that actually receives a byte when the autobauding has succeeded (Due to interrupt latency, the actual routine to receive a byte is called from main(), though.). The timer is also used to send bytes to the device when a byte is received from the PC.

« Prev 3 Next »


© 2006-2022 Sprite_tm - Contact