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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #19669: Need function to read signature row

Submitter:  Bill Johnson <billj>
Submitted:  Mon 23 Apr 2007 08:39:21 PM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Header files
Status:  Fixed Assigned to:  joerg_wunsch
Percent Complete:  0% Open/Closed:  Closed
Release:  None Fixed Release:  None

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.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-12-18 joerg_wunsch StatusNone Fixed
        Assigned toNone joerg_wunsch
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code