[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

View: New views
7 Messages — Rating Filter:   Alert me  

[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


URL:
  <http://savannah.nongnu.org/bugs/?27198>

                 Summary: avr/iox128a1.h is missing definitions for
calibration signature indexes
                 Project: AVR C Runtime Library
            Submitted by: simonk
            Submitted on: Fr 07 Aug 2009 01:27:14 GMT
                Category: Header
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.7.*
           Fixed Release: None

    _______________________________________________________

Details:

There are no #defines or enums defining an index for each possible
production/calibration signature row entry/register.
This index has to be loaded into ZL when using LPM on the NVM to load
production signature entries.

It could look like:

typedef enum NVM_PROD_SIG_IDX_enum
{
        NVM_PROD_SIG_IDX_RCOSC2M = 0x00,
        NVM_PROD_SIG_IDX_RCOSC32K = 0x02,
        NVM_PROD_SIG_IDX_RCOSC32M = 0x03,
        NVM_PROD_SIG_IDX_LOTNUM0 = 0x08,
        NVM_PROD_SIG_IDX_LOTNUM1 = 0x09,
        NVM_PROD_SIG_IDX_LOTNUM2 = 0x0A,
        NVM_PROD_SIG_IDX_LOTNUM3 = 0x0B,
        NVM_PROD_SIG_IDX_LOTNUM4 = 0x0C,
        NVM_PROD_SIG_IDX_LOTNUM5 = 0x0D,
        NVM_PROD_SIG_IDX_WAFNUM = 0x10,
        NVM_PROD_SIG_IDX_COORDX0 = 0x12,
        NVM_PROD_SIG_IDX_COORDX1 = 0x13,
        NVM_PROD_SIG_IDX_COORDY0 = 0x14,
        NVM_PROD_SIG_IDX_COORDY1 = 0x15,
        NVM_PROD_SIG_IDX_ADCACAL0 = 0x20,
        NVM_PROD_SIG_IDX_ADCACAL1 = 0x21,
        NVM_PROD_SIG_IDX_ADCBCAL0 = 0x24,
        NVM_PROD_SIG_IDX_ADCBCAL1 = 0x25,
        NVM_PROD_SIG_IDX_TEMPSENSE0 = 0x2E,
        NVM_PROD_SIG_IDX_TEMPSENSE1 = 0x2F,
        NVM_PROD_SIG_IDX_DACAOFFCAL = 0x30,
        NVM_PROD_SIG_IDX_DACAINCAL = 0x31,
        NVM_PROD_SIG_IDX_DACBOFFCAL = 0x32,
        NVM_PROD_SIG_IDX_DACBINCAL = 0x33
} NVM_PROD_SIG_IDX_t

a function for reading the signature data could look like:
/* static inline */
uint8_t SystemReadCalibrationByte(NVM_PROD_SIG_IDX_t Index)
{
        uint8_t Result;

        __asm__ volatile (
        "mov r30, %[Idx]" "nt"
        "ldi r31, 0" "nt"
        "ldi %[Idx], %[Rd]" "nt"
        "sts %[Cmd], %[Idx]" "nt"
        "lpm %[Res], Z" "nt"
        : [Res] "=r" (Result)
        : [Idx] "a" ((uint8_t) Index),
          [Rd]  "M" (NVM_CMD_READ_CALIB_ROW_gc),
          [Cmd] "m" (NVM_CMD)
        );

        return Result;
}




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27198>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #1, bug #27198 (project avr-libc):

Maybe r30 and r31 have to get clobbered. Im not so much into
inline-assembler.
I also appended the code as a text file.

(file #18535)
    _______________________________________________________

Additional Item Attachment:

File name: signaturerow.txt               Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27198>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #2, bug #27198 (project avr-libc):

Yes Z (r30,r31) would have to be clobbered.

You have to change your "nt" to "nt" to truly get newline and tab
characters.

I have doubts about this line:
"ldi %[Idx], %[Rd]" "nt"
I'm not sure what you're trying to do there.

And you probably need to double check your constraints that you're using.

But the work that you've done so far is very appreciated! :-) Would you be
willing to keep working on the inline assembly and get it working and tested?
You can look at other inline assembly constructs in avr-libc for working
examples.



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27198>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #3, bug #27198 (project avr-libc):

First, as I already said Im not so much into inline-assembler.

What comes to the nt's I don't know who converted it from nt to nt on the
long way of copy and pasting. In the text file it's correct.

I also haven't found a way to use ZH/ZL instead of r30, r31.

In this line
"ldi %[Idx], %[Rd]"
I just needed a temporary Register to copy the NVM_CMD_READ_CALIB_ROW_gc. So
i used this register. I almost believe that there is a better solution, which
is easier to understand.

The constraints I got from a German page
(http://www.rn-wissen.de/index.php/Inline-Assembler_in_avr-gcc).
It says "r" for any register, M for an 8 Bit Constant, m for a memory address
(I believe?) and d for an upper register. So I think anything should be fine,
but Im open to tips or hints.

I've already tested the assembly within the attached text-file and it works
so far. I can read all calibration row entries.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27198>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #4, bug #27198 (project avr-libc):

Maybe this one is better. It works fine as far as I can test it (Just reading
LOTNUM3).

See signaturerow2.txt

(file #18537)
    _______________________________________________________

Additional Item Attachment:

File name: signaturerow2.txt              Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27198>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: [bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Bob Paddock-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> There are no #defines or enums defining an index for each possible
> production/calibration signature row entry/register.

 NVM_PROD_SIGNATURES_t;?

/* Example of reading Product Signatures in C with standard XMega XML
header file: */

#include <stdint.h> /* uint8_t et.al */
#include <stddef.h> /* offsetof() */
#include <avr/io.h>

/* From application note AVR1316: */
#include "avr_compiler.h" /* Compile with GCC release of
WinAVR20090313 or newer */
#include "sp_driver.h"

/* Change hex8() to match what your hardware needs to display a byte */
#define hex8(x) do{ /* display byte here */ }while(0)

int main( void )
{
  /* Read the part signature and revision: */
  hex8( MCU.DEVID0 ); hex8( MCU.DEVID1 ); hex8( MCU.DEVID2 );
  hex8( (uint8_t) (MCU.REVID+'A') );

  /* Device serial number: */
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
LOTNUM0 ) ) ); /* First read after reset or possibly Power Up returns
zero */

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM1 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM2 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM3 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM4 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM5 ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, WAFNUM ) )  );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDX0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDX1 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDY0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDY1 ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
TEMPSENSE0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
TEMPSENSE1 ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCACAL0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCACAL1 ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCBCAL0 ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCBCAL1 ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
DACAOFFCAL ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
DACACAINCAL ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
DACBOFFCAL ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
DACBGAINCAL ) ) );

  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC2M ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC32K ) ) );
  hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC32M ) ) );
}


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: [bug #27198] avr/iox128a1.h is missing definitions for calibration signature indexes

by Simon Küppers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Still there are no defines or enums. The type you mentioned is a struct.
But I can't see the advantage of a struct in this case.
A Caller to the signature-row-read-function has to use offsetof() to
define the index first.
So I think #defines would be appreciated.
Also I think, that it would be a good idea to include the
read-calibration-byte functions in avr-libc so there is no need to
implement these functions in each project sperately.

Mit freundlichen Grüßen

        Simon Küppers



Bob Paddock schrieb:

>> There are no #defines or enums defining an index for each possible
>> production/calibration signature row entry/register.
>>    
>
>  NVM_PROD_SIGNATURES_t;?
>
> /* Example of reading Product Signatures in C with standard XMega XML
> header file: */
>
> #include <stdint.h> /* uint8_t et.al */
> #include <stddef.h> /* offsetof() */
> #include <avr/io.h>
>
> /* From application note AVR1316: */
> #include "avr_compiler.h" /* Compile with GCC release of
> WinAVR20090313 or newer */
> #include "sp_driver.h"
>
> /* Change hex8() to match what your hardware needs to display a byte */
> #define hex8(x) do{ /* display byte here */ }while(0)
>
> int main( void )
> {
>   /* Read the part signature and revision: */
>   hex8( MCU.DEVID0 ); hex8( MCU.DEVID1 ); hex8( MCU.DEVID2 );
>   hex8( (uint8_t) (MCU.REVID+'A') );
>
>   /* Device serial number: */
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> LOTNUM0 ) ) ); /* First read after reset or possibly Power Up returns
> zero */
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM1 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM2 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM3 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM4 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, LOTNUM5 ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, WAFNUM ) )  );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDX0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDX1 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDY0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, COORDY1 ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> TEMPSENSE0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> TEMPSENSE1 ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCACAL0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCACAL1 ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCBCAL0 ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, ADCBCAL1 ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> DACAOFFCAL ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> DACACAINCAL ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> DACBOFFCAL ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t,
> DACBGAINCAL ) ) );
>
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC2M ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC32K ) ) );
>   hex8( SP_ReadCalibrationByte( offsetof( NVM_PROD_SIGNATURES_t, RCOSC32M ) ) );
> }
>
>  


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev