How to read ADCA manufacture signature calibration data ?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sir./Madam,

 

Could you please help me in reading ADCA manufacture signature calibration data ?

Stepping my code as following and failing in reading the values.

 

Sincerely,

Liu Wang

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How are you reading the registers in your code?? There is nothing there.

 

Post a small compilable project.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PRODSIGNATURES_ADCACAL0 and 1 are not calibration values but the addresses of the memories where the values are stored.

 

#include <avr/pgmspace.h>

    ADCA.CALL =	ReadCalibrationByte(PRODSIGNATURES_ADCACAL0);
    ADCA.CALH = ReadCalibrationByte(PRODSIGNATURES_ADCACAL1);

uint8_t ReadCalibrationByte( uint8_t index ){
    uint8_t reg = (SREG);
    cli();
    /* Load the NVM Command register to read the calibration row. */
    NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
    uint8_t result = pgm_read_byte(index);
    /* Clean up NVM Command register. */
    NVM.CMD = NVM_CMD_NO_OPERATION_gc;
    (SREG) = reg;
    return (result);
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Js & John,

 

Appreciate your kind review and strong comments.

Sounds the ADCA_CALH is not writable.

Anymore comments are welcomed.

 

Sincerely,

Liu Wang

 

/*---temp.c---*/

#include <avr/io.h>
#include "Temp.h"
#include <avr/interrupt.h>

 

 

oid TempInit( )
{
  ADCA_CTRLA = 0x05; //DMASEL[1:0]:No combined DMA request. CHSTART[3:0]:Hold on conversion. FLUSH: Pipeline Flush. ENABLE: Enable ADC.
  ADCA_CTRLB = 0x08;//CONVMODE: Conversion Mode unsigned. FREERUN: Free Running Mode. RESOLUTION[1:0]: Conversion Result Resolution:12-bit result, right adjusted.
  ADCA_REFCTRL = 0x01;//REFSEL[1:0]: Reference Selection:10/11 of bandgap (1.0V). BANDGAP: Bandgap disabled. TEMPREF: Temperature Reference Enabled.
  ADCA_EVCTRL = 0x00;//SWEEP[1:0]: Only channel #0.EVSEL[2:0]: Event Channel #7. EVACT[2:0]: EVACT[2:0]: event mode: No event input.
  ADCA_PRESCALER = 0x07;//PRESCALER[2:0]: DIV 512.
  CCP = 0xD8; //Signature of IO protected register.
  ADCA_CALL = 0x80;//PRODSIGNATURES_ADCACAL0;//TEMPSENSE0;
  ADCA_CALH = 0x0a;//PRODSIGNATURES_ADCACAL1;//TEMPSENSE1;
  ADCA_CH0_CTRL = 0x80;//Start conversion, Gain factor = 1x, Internal positive input.
  ADCA_CH0_MUXCTRL = 0x00;//MUX positive input: Temperature reference. MUX Negative: N / A for internal positive input.
  ADCA_CH0_INTCTRL = 0x00;//Interrupt mode: N / A, Interrupt level = disabled.

}

 

/*---main.c---*/

int main(void)
{  

  TempInit();
  
  while (1) 
  {
  }

  return 0;

}

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Madam / Sir,

 

When hardcoded ADCA_CALH is not writable while ADCA_CALL is writable.

Looks ADCA_CALH is protected for illegal accidental writing.

Any comments on the mechanism to enable ADCA_CALH writable would be appreciated.

 

Sincerely,

Liu Wang

===

Code segment: 

Debugging IO watch window: