MY PROJECTS
robotics - electronics - machining
  Friday November 22nd 2024 06:23:52 PM

Using Avrdude

So you're just getting started with Atmel AVR programming and you can't figure out how to use AVRDUDE. This is not intended to be an exhaustive guide to AVRDUDE, rather a simple guide to some of the command line switches you will need to know to use AVRDUDE. The chip chosen for the example is the atmega168 which is a common 8 bit AVR. If you are using a different AVR chip you can refer to the AVR FUSE CALCULATOR to find the desired settings for your chip.

In this example we will be using the USB-Tiny programmer as the hardware device. 


This programmer has been supported by AVRDUDE 5.5 and forward.

For Windows users open a CMD line window for the following tasks.

FUSE BITS

"Whats my fuses?" 

People get 0 and 1 all mixed up when handling fuses, right. So one practical way to make sure a 'ON' is a '0' is to check:

1) Can you communicate with the chip through ISP?
2) What is the SPI fuse bit set to?
3) That is what 'ON' is.

To read the current device lfuse and hfuse to the console:
avrdude -c usbtiny -p m168 -U lfuse:r:con:r -U hfuse:r:con:r

To read the current devide lfuse and hfuse to a file:
avrdude -c usbtiny -p m168 -U lfuse:r:C:\lfuse.txt:r -U hfuse:r:C:\hfuse.txt:r

To write the desired fuse settings to lfuse:
avrdude -c usbtiny -p m168 -U lfuse:w:0x62:m -u

To write the desired fuse settings to hfuse:
avrdude -c usbtiny -p m168 -U hfuse:w:0xDF:m -u

To write the desired fuse settings to efuse:
avrdude -c usbtiny -p m168 -U efuse:w:0xF9:m -u

(Note: in the above example we used the factory default settings for safety)

PROGRAM FILE

To write a hex file to the device: 
avrdude -c usbtiny -p m168 -U flash:w:"C:\test.hex":a -D -e

To verify the contents of the device with the hex file: 
avrdude -c usbtiny -p m168 -U flash:v:"C:\test.hex":a -D -e

 To write the contents of the device to a file:
avrdude -c usbtiny -p m168 -U flash:r:"C:\test.hex":a -D -e

Following are the standard Atmel programmer pinouts. Not to confuse you, these are not all available on all chips. Check your chip's data sheet to determine which plug pinout applies.




Copyright © Tom_L 2009-2020