OwenDuffy.net 


Simple Morse beacon keyer - using ATB

ATB is a boot loader for ATTiny chips, see ATB - a bootloader for AVR Tiny microcontrollers.

This note provides information on using ATB with the Simple Morse beacon keyer.

The fuse options give below set the BOD level to 4.3V. It is advisable when using a bootloader to have BOD enabled to minimise the risk of corruption of flash. If used with Vcc less than 5V, change the fuses for an appropriate threshold.

ATTinyx5x (crystal option)

ATB consumes about 600 bytes of flash memory, so it is advisable to use a 4K ATTiny or larger, eg ATTiny45.

rem generate the bootloader
ATBU -s 2600 -oG:t45.hex -rb0 -tb0 -f tn45.hex

rem write the bootloader to flash
avrdude -P usb -c avrisp2 -p t45 -U flash:w:tn45.hex
sleep 2

rem set the fuses
avrdude -P usb -c avrisp2 -p t45 -U hfuse:w:0xDC:m -U lfuse:w:0x7f:m efuse:w:0xfe:m

Above is a batch file of the commands to generate the bootloader firmware, program the bootloader, and set the fuses. The fuses set the BOD level to 4.3V.

@echo off

set ATB=atbu
set ATBOPTS=-ccom14:38400
set EFILE=smbk-vk1od-18432.hex
set FFILE=QrssBeacon-tx5x.hex

echo Check contact
%ATB% %ATBOPTS% -oI
rem echo el is %ERRORLEVEL%
if errorlevel 1 goto bad
rem sleep 1

echo Program flash from %FFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oFW -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify flash...
rem pause >nul
%ATB% %ATBOPTS% -oFV -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Program EEPROM from %EFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oEW -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify EEPROM...
rem pause >nul
%ATB% %ATBOPTS% -oEV -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo All done

goto end

:bad
echo failed...
:end

Above is a batch file to load the application firmware and EEPROM using ATB.

The configuration above uses ATB in single wire mode on pin B0 of the ATTinyx5, pin 5 on the DIP package. A 10k pull-up resistor should be connected from B0 to Vcc.

Note that the selection switch ??speed[0] must be open during ATB operations.

ATTinyx5

ATB consumes about 600 bytes of flash memory, so it is advisable to use a 4K ATTiny or larger, eg ATTiny45 (though current ATTinyx5 fits on an ATTiny25 along with ATB).

rem generate the bootloader
ATBU -s 2600 -oG:t45.hex -rb1 -tb1 -f tn45.hex

rem write the bootloader to flash
avrdude -P usb -c avrisp2 -p t45 -U flash:w:tn45.hex
sleep 2

rem set the fuses
avrdude -P usb -c avrisp2 -p t45 -U hfuse:w:0xDC:m -U lfuse:w:0x62:m -U efuse:w:0xfe:m

Above is a batch file of the commands to generate the bootloader firmware, program the bootloader, and set the fuses. The fuses above are for the internal RC clock. The fuses set the BOD level to 4.3V.

@echo off

set ATB=atbu
set ATBOPTS=-ccom14:38400
set EFILE=smbk-vk1od-18432.hex
set FFILE=QrssBeacon-tx4.hex

echo Check contact
%ATB% %ATBOPTS% -oI
rem echo el is %ERRORLEVEL%
if errorlevel 1 goto bad
rem sleep 1

echo Program flash from %FFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oFW -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify flash...
rem pause >nul
%ATB% %ATBOPTS% -oFV -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Program EEPROM from %EFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oEW -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify EEPROM...
rem pause >nul
%ATB% %ATBOPTS% -oEV -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo All done

goto end

:bad
echo failed...
:end

Above is a batch file to load the application firmware and EEPROM using ATB.

The configuration above uses ATB in single wire mode on pin B1 of the ATTiny4x, pin 6 on the DIP package. A 10k pull-up resistor should be connected from B1 to Vcc.

Note that the selection switch speed[0] must be open during ATB operations.

ATTinyx4

ATB consumes about 600 bytes of flash memory, so it is advisable to use a 4K ATTiny or larger, eg ATTiny44.

rem generate the bootloader
ATBU -s 2600 -oG:t44.hex -ra0 -ta0 -f tn44.hex

rem write the bootloader to flash
avrdude -P usb -c avrisp2 -p t44 -U flash:w:tn44.hex
sleep 2

rem set the fuses
avrdude -P usb -c avrisp2 -p t44 -U hfuse:w:0xDC:m -U lfuse:w:0x62:m -U efuse:w:0xfe:m

Above is a batch file of the commands to generate the bootloader firmware, program the bootloader, and set the fuses. The fuses above are for the internal RC clock, if the crystal option is used set the lower fuse to 0x7F: -U lfuse:w:0x7F:m. The fuses set the BOD level to 4.3V.

@echo off

set ATB=atbu
set ATBOPTS=-ccom14:38400 -v
set EFILE=smbk-vk1od-18432.hex
set FFILE=QrssBeacon-tx4.hex

echo Check contact
%ATB% %ATBOPTS% -oI
rem echo el is %ERRORLEVEL%
if errorlevel 1 goto bad
rem sleep 1

echo Program EEPROM from %EFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oEW -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify EEPROM...
rem pause >nul
%ATB% %ATBOPTS% -oEV -f %EFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Program flash from %FFILE% ...
rem pause >nul
%ATB% %ATBOPTS% -oFW -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo Verify flash...
rem pause >nul
%ATB% %ATBOPTS% -oFV -f %FFILE%
if errorlevel 1 goto bad
rem sleep 1

echo All done

goto end

:bad
echo failed...
:end

Above is a batch file to load the application firmware and EEPROM using ATB.

The configuration above uses ATB in single wire mode on pin A0 of the ATTinyx4, pin 13 on the DIP package. A 10k pull-up resistor should be connected from A0 to Vcc.

Note that the selection switch speed[0] must be open during ATB operations.

C:\src\QrssBeacon\ATB>doit
Check contact

Utility for Avr Tiny Bootloader (ATB), v1.1.

Press reset on target and hit ENTER to continue...

Echo cancellation activated.
Communication established, boot loader activated.

AVR TINY BOOTLOADER (ATB)
Version : 1.1.0
Signature : 1E 92 07
PAGESIZE : 64
FLASHSIZE : 3392
EEPROM : 256
TIMEOUT : 2600


Program EEPROM...

Utility for Avr Tiny Bootloader (ATB), v1.1.

Press reset on target and hit ENTER to continue...

Writing EEPROM from file test.hex.
Echo cancellation activated.
Communication established, boot loader activated.

100% ##################################################

Write done.

Verify EEPROM...

Utility for Avr Tiny Bootloader (ATB), v1.1.

Press reset on target and hit ENTER to continue...

Vefifying EEPROM with file test.hex.
Echo cancellation activated.
Communication established, boot loader activated.
100% ##################################################
Verified OK

Program flash...

Utility for Avr Tiny Bootloader (ATB), v1.1.

Press reset on target and hit ENTER to continue...

Writing FLASH from file C:\src\QrssBeacon\QrssBeacon-tx4\Release\QrssBeacon-tx4.
hex.
Echo cancellation activated.
Communication established, boot loader activated.

100% ##################################################

Write done.

Verify flash...

Utility for Avr Tiny Bootloader (ATB), v1.1.

Press reset on target and hit ENTER to continue...

Verifying FLASH with file C:\src\QrssBeacon\QrssBeacon-tx4\Release\QrssBeacon-tx
4.hex.
Echo cancellation activated.
Communication established, boot loader activated.
100% ##################################################
Verified OK

All done

Above is the console output from a batch file to load the eeprom and flash.

 

Links

Changes

Version Date Description
1.01 20/09/2012 Initial.
1.02    
1.03    
1.04    
1.05    

 


© Copyright: Owen Duffy 1995, 2021. All rights reserved. Disclaimer.