[TUT][SOFT] Calibration using AVR053 under Linux

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel application note AVR053 describes a method for using AVR programmers to calibrate the internal RC oscillator. Unfortunately, it's fairly Windows / Atmel Studio specific. Here are the steps I ended up following to use it under Linux.

First, get a copy of the gavrasm AVR assembler from http://www.avr-asm-tutorial.net/.... If you're using 64-bit Linux, you should be able to download and use the provided binary. If you're using 32-bit, you'll need to get the source and compile it yourself:

  1. Install the FreePascal compiler (under Ubuntu, sudo apt-get install fp-compiler)
  2. Download and unpack the gavrasm source
  3. For English messages, copy gavrlang_xx.pas to gavrlang.pas
  4. Compile it: pc gavrasm.pas

Next, compile the calibration program:

  1. Get the source from http://www.avrfreaks.net/index.p... and unpack it somewhere
  2. Replace backslashes with forward slashes: sed -i 's|\\|/|g' RC_Calibration.asm */*.inc */*.asm
  3. Someone didn't pay attention to case, so link Common to common: ln -s Common common
  4. Edit RC_Calibration.asm
    1. Comment out the default device and uncomment your device
    2. If needed, comment out the default programmer and uncomment your programmer
    3. If needed, change the target frequency and accuracy
  5. Compile it: /path/to/gavrasm RC_Calibration.asm

Now you can use AVRdude to perform the calibration:

  1. Program your AVR with RC_Calibration.hex
  2. Run the calibration: avrdude [other flags] -O (that's dash oh, not dash zero)
  3. Download the EEPROM values: avrdude [other flags] -U eeprom:r:/tmp/eeprom.txt:d
  4. The first number in /tmp/eeprom.txt is the new calibrated value

You may wish to set the EESAVE fuse to stop the EEPROM from being cleared when the flash is cleared - otherwise you'll need to reprogram the calibration byte every time you reprogram your AVR.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have used JTAGICEII.exe in windows for long time and it works fine for calibrating the internal RC. I want to start using avrdude but nothing is written to eeprom when I invoke the -O flag. After calibration the eeprom is still empty, also addr 0x00. I don't get any error code.

Is it possible there is something wrong with my part ATmega32m1 in the /etc/avrdude.conf file?

I am using avrdude 5.11. in ubuntu 12.04

This is my command:
$ avrdude -p m32m1 -c jtag2isp -P usb -O
avrdude: performing RC oscillator calibration
avrdude: calibration value is now stored in EEPROM at address 0

avrdude done. Thank you.