AnsweredAssumed Answered

TWR-KM34Z75M AFE Readings

Question asked by Edriano Araujo on Sep 17, 2015
Latest reply on Sep 21, 2015 by Edriano Araujo

Hello All.

 

I am testing the AFE 24 bits and it is working but.

I short circuit the ADP0 and ADM0 and get readings of -48000 the readings are steady they are not varying a lot.

Is that normal this offset?

the clock i am using is 4MHz internal.

void Configura_Afe_24bits(void)
{
  SIM_SCGC6 |=  (SIM_SCGC6_AFE_MASK);  //habilita modulo AFE 24 bits
  SIM_SCGC4 |=  SIM_SCGC4_VREF_MASK; // HABILITA PERIFERICO GERADOR DE REFERENCIA
  
  VREF_VREFH_SC = VREF_VREFH_SC_VREFEN_MASK + VREF_VREFH_SC_REGEN_MASK
                  + VREF_VREFH_SC_ICOMPEN_MASK + VREF_VREFH_SC_MODE_LV(1);
  
  AFE_CH0_CFR = (   AFE_CFR_DEC_OSR(5)
                  + AFE_CFR_PGA_EN_MASK
                  + AFE_CFR_PGA_GAIN_SEL(1)
                  + AFE_CFR_BYP_MODE(0)
                  + AFE_CFR_SD_MOD_EN_MASK
                  + AFE_CFR_DEC_EN_MASK
                  + !AFE_CFR_CC_MASK
                  + AFE_CFR_DEC_CLK_EDGE_SEL(0)
                  + AFE_CFR_DEC_CLK_INP_SEL(0)
                  + !AFE_CFR_HW_TRG_MASK
                 );
  
  AFE_CH1_CFR = AFE_CH0_CFR;
  AFE_CH2_CFR = AFE_CH0_CFR;
  AFE_CH3_CFR = AFE_CH0_CFR;

  AFE_CR = (  AFE_CR_MSTR_EN_MASK
              + !AFE_CR_LPM_EN_MASK
              + AFE_CR_RST_B_MASK   
              + !AFE_CR_DLY_OK_MASK
              + AFE_CR_RESULT_FORMAT_MASK
              + AFE_CR_STRTUP_CNT(0)
            );  
}






void Ler_Afe_Adc(void)
{
  AFE_CR |= AFE_CR_SOFT_TRG0_MASK;
  while((AFE_SR & AFE_SR_COC0_MASK)==0)
  {
  }
  resultado = AFE_CH0_RR;

}

Outcomes