4 Performing Calibration

The command line tool atprogram is used for initiating the calibration sequence. This application is included in the Atmel Studio 7.0 installation, and it connects to a supported AVR programming tool to generate the required calibration clock signal. Upon successful calibration, the atprogram tool can also be used to read the resulting oscillator calibration bytes from EEPROM.

The following programming tools support the calibration protocol:

  • Atmel ICE
  • Power Debugger
  • JTAGICE3
Prerequisites for the calibration procedure:
  • The exact calibration clock frequency has been measured.
  • The target has been programmed with the calibration firmware and has been provided with the exact calibration clock frequency.
A calibration sequence can be initiated in the following way:
  1. Connect the selected programming tool to the target device using the JTAG interface.
  2. Connect the programming tool to the computer running Atmel Studio 7.0 and power-up the target device.
  3. In Atmel Studio 7.0, open the command line by selecting Tools → Command Prompt.
  4. In the command prompt, run the following command to initiate the calibration:

    atprogram -t [tool] -d [device] calibrate

    Example: atprogram -t atmelice -d atxmega128a1u calibrate

    Upon successful calibration the command returns with the message:
    Oscillator calibration sequence succeeded
  5. If needed, the resulting calibration bytes can be read from the EEPROM with the atprogram "read" command. If the five oscillator calibration bytes on an XMEGA128A1U are stored in bytes 0-4 on page 0 in EEPROM, this should be specified in the command along with the desired output format.

    Example: atprogram -t atmelice -i jtag -xr -d atxmega128a1u read -ee -o 0 -s 5 --format hex

    The expected output and format from this command is:
    Firmware check OK
    400A400D89
    The five bytes will be printed in hexadecimal format starting with the byte stored at the lowest address. If the bytes are stored in the following order: [DFLLRC32M.CALA][DFLLRC32M.CALB][DFLLRC2M.CALA][DFLLRC2M.CALB][OSC.RC32KCAL], the first 0x40 value would represent the value of DFLLRC32M.CALA. The values illustrated here are examples only.
Note: The atprogram tool also supports writing the read-command result directly to file.
Note: Run atprogram without arguments to display documentation and available options. The atprogram tool can also be accessed directly from the installation path of Atmel Studio 7.0 in the folder atbackend.