bugAVR C Runtime Library - Bugs: bug #19669, Need function to read signature row

 
 

bug #19669: Need function to read signature row

Submitted by:  Bill Johnson <billj>
Submitted on:  Mon 23 Apr 2007 08:39:21 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: FixedPercent Complete: 0%
Assigned to: Joerg Wunsch <joerg_wunsch>Open/Closed: Closed
Release: NoneFixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 23 Apr 2007 08:39:21 PM UTC, original submission:

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; \
}))

Bill Johnson <billj>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Updated the item)
  • -unavailable- added by billj (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 18 Dec 2007 10:22:28 PM UTCjoerg_wunschStatusNone=>Fixed
      Assigned toNone=>joerg_wunsch
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1