8

While programming an ATtiny or ATmega, avrdude prints the device signature, in this example it is an ATtiny.

avrdude: Device signature = 0x1e910a

Can I read this signature on a running device using C++ code (avr-gcc)? For ATmega1280 there is a chapter 29.6.10 writing about it, but I'm a bit puzzled by how I can code it in C++.

I want to be able to make the device send its device ID back to the controlling PC, so the PC can make decisions on it.

tyblu
  • 8,167
  • 6
  • 40
  • 70
jippie
  • 33,033
  • 16
  • 93
  • 160
  • This question is closely related: http://electronics.stackexchange.com/questions/58386/how-can-i-detect-which-arduino-board-or-which-controller-in-software/58388#58388 – jippie Feb 20 '13 at 21:28

1 Answers1

7

You can use these macros that get defined automatically when you include <avr/io.h>:

SIGNATURE_0
SIGNATURE_1
SIGNATURE_2

For ATmega1280, they're defined as:

/* Signature */
#define SIGNATURE_0 0x1E
#define SIGNATURE_1 0x97
#define SIGNATURE_2 0x03

in iom1280.h (which is automatically included through <avr/io.h> when you compile code for the m1280)

For example, this will send the three bytes via UART:

uart_putc(SIGNATURE_0)
uart_putc(SIGNATURE_1)
uart_putc(SIGNATURE_2)

If you truly want to read the fuses, you'd need to use boot_signature_byte_get macro from <avr/boot.h>

ksk
  • 316
  • 1
  • 3
  • I used `boot_signature_byte_get( 0x00 )`, `boot_signature_byte_get( 0x02 )`, `boot_signature_byte_get( 0x04 )` – jippie May 12 '12 at 12:42