[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #19669] Need function to read signature row
From: |
Bill Johnson |
Subject: |
[avr-libc-dev] [bug #19669] Need function to read signature row |
Date: |
Mon, 23 Apr 2007 20:39:23 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2 |
URL:
<http://savannah.nongnu.org/bugs/?19669>
Summary: Need function to read signature row
Project: AVR C Runtime Library
Submitted by: billj
Submitted on: Monday 04/23/2007 at 20:39
Category: Header
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Header files
Status: None
Privacy: Public
Percent Complete: 0%
Assigned to: None
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Greetings,
The ATmega406 (and some others?) allows access to a signature row of data. It
contains signature bytes as well as device specific factory calibration
values. I can find no libc function to access it. It requires special timing
to access the data space. There is a discussion about it at:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=48859
I have a possible fix below. It seems to work OK but I don't know inline ASM
macro language and pieced it together from similar macros so it could have
some issues. From discussion it should probably go in boot.h. Interrupts
should be disabled during use, maybe that should be in the macro.
+BillJ
/** \ingroup avr_boot
\def signature_byte_get(address)
Read the Signature Row byte at \c address.
Parameter \c address can be 0-0x1f as define for supporting processors.
\note The values are processor dependent.
*/
#define __BOOT_SIGROW_READ (_BV(SPMEN) | _BV(SIGRD))
#define signature_byte_get(addr) \
(__extension__({ \
uint16_t __addr16 = (uint16_t)(addr); \
uint8_t __result; \
__asm__ \
( \
"sts %1, %2\n\t" \
"lpm %0, Z" "\n\t" \
: "=r" (__result) \
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
"r" ((uint8_t) __BOOT_SIGROW_READ),\
"z" (__addr16) \
); \
__result; \
}))
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?19669>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] [bug #19669] Need function to read signature row,
Bill Johnson <=