Hannes Lux schrieb:
> Ja eben, deshalb will er ja wissen, wie man das Calibrationsbyte für
> 8MHz per AVRDUDE aus dem High-Byte der Adresse 3 des Signature-Bereichs
> ausliest.
"man avrdude" fördert das hier zutage:
1 | -U memtype:op:filename[:format]
|
2 | Perform a memory operation as indicated. The memtype field specifies the memory type to operate
|
3 | on. The available memory types are device-dependent, the actual configuration can be viewed with
|
4 | the part command in terminal mode. Typically, a device's memory configuration at least contains
|
5 | the memory types flash and eeprom. All memory types currently known are:
|
6 | calibration One or more bytes of RC oscillator calibration data.
|
7 | eeprom The EEPROM of the device.
|
8 | efuse The extended fuse byte.
|
9 | flash The flash ROM of the device.
|
10 | fuse The fuse byte in devices that have only a single fuse byte.
|
11 | hfuse The high fuse byte.
|
12 | lfuse The low fuse byte.
|
13 | lock The lock byte.
|
14 | signature The three device signature bytes (device ID).
|
15 | fuseN The fuse bytes of ATxmega devices, N is an integer number for each fuse supported by
|
16 | the device.
|
17 | application The application flash area of ATxmega devices.
|
18 | apptable The application table flash area of ATxmega devices.
|
19 | boot The boot flash area of ATxmega devices.
|
20 | prodsig The production signature (calibration) area of ATxmega devices.
|
21 | usersig The user signature area of ATxmega devices.
|
Es muss also "prodsig" als "memtype" angegeben werden. Auf diese Weise
liest man den Kalibrierungswert aus und schreibt ihn (ebenfalls mit
AVRDUDE) ins EEPROM. Das Programm auf dem Mikrocontroller kann sich dann
den Wert aus dem EEPROM holen und ihn ins Register OSCCAL schreiben.
Sinnigerweise sollte man das Fusebit EESAVE auf 0 setzen, damit der
EEPROM-Inhalt beim späteren Neuschreiben des Flashspeichers nicht
verloren geht.
Alternativ kann man den Kalibrierungswert natürlich auch gleich als
Konstante ins Programm schreiben. Das muss man aber für jeden Chip
einzeln machen, wenn das Programm auf mehreren Mikrocontrollern mit
kalibriertem 8-MHz-Oszillator laufen soll.
Ein dritter Weg wäre, den Mikrocontroller per Programm sich selbst
kalibrieren zu lassen. Dazu muss man ihm einmal eine konstante
Zeitquelle per I/O-Pin zur Verfügung stellen.