Posts

Showing posts from March, 2017

A tale of two UART devices

Image
Resolving UART bus conflicts and voltage levels I wanted to record two potential issues I found with using my custom Atmega328p board with onboard USB FT232 when an HC-05 bluetooth module in introduced, in the hope it may well be helpful to others. Above:   A small piece of perfboard modifies the Bluetooth socket to include a 5V to 3.3V voltage divider on the Bluetooth HC-05 RX line (10 and 20kohm resistors).  The red wire provides a direct line from the Bluetooth HC-05 TX output and the Atmega328p RX input, thereby granting it preference when the HC-05 module is present.  It's not quite clear from the picture, but the RX input pin is bent up out of the socket and a 1k resistor connects the FT232 TX output (see below).

Customising Optiboot

Image
I wanted to setup programming my custom Atmega328p board over Bluetooth.  Some have used the connection pin to control the Reset pin of the AVR.  However I want to use Bluetooth constantly, and only trigger a reset upon receiving a specific string sequence.  This requires tweaking the bootloader, using Optiboot as a basis: (1) Change Baudrate to be mutually compatible with Bluebooth and AVR. (2) Set an EEPROM byte in the main application, which could be read (and written) in the Optiboot routine. Setting up Optiboot in the Atmel environment: - Setup a project as usual in Atmel Studio - Copy files over from github to the project folder: optiboot.c, pindefs.h, stk500.h and boot.h. EDIT: It seems there is an AtmelStudio folder already set up on github . Setting baud rate to be compatible with AVR and Bluetooth module: 57600 bps - Insert #define BAUD_RATE 57600 (as required) into optiboot.c . - Compile and link project with following settings: Compiler Misc: -g -Wall -O