Monday, 25 April 2011

FTDI, Library Troubles, and an Incorrect Crystal Frequency

After a lot of stuffing about, I've finally got my USART transmitting characters at the correct baud rate.
Since my last post, I've create a little FTDI serial to USB interface board that fits inside my Primer 2. It's fairly dodgy since it was rushed and made at home using the Kinsten etching method, but it works and brings USB serial, along with SPI, I2C and CAN pins, to the outside of the device.



The hardware worked flawlessly the first time (althought I think I should be driving the LEDs from VCC2V8 (2.8V) rather than VCC (5V from the USB port), but the software was an issue. The baud rate was being doubled for some strange reason, and after looking through the libraries without much explanation, I discovered that the 'stm32f10x_conf.h' sets the STM32's clock source to 8MHz which I believed was correct, but the crystal on the Primer 2 is actually 12MHz. If only I'd checked the schematic.

After this was changed, the 115200 baud rate correctly transmitted the single ASCII characters I was testing with.

Changing libraries took a bit of time to get used to since the newer ones handle a few things differently, but I think I'm fairly well sorted now.

Hopefully I can get some basic USART and complex number libraries working tomorrow. If work and Portal 2 don't interfere that is. :)

EDIT: After making a slight modification (cutting two tracks and adding two extra wires to disconnect the LEDs from VCC and reconnect them to VCC2V8) the LEDs now stay completely off when no data is transmitting.










No comments:

Post a Comment