Post Go back to editing

Reading Temperature from ADUCM360 from CN0359 Kit Problem

in EVAL-CN0359-EB1Z Open source code ,  we want to change the adc1  to read the Internal Temp Sensor inside the ADUCM360 .

 

We do the changes in the below ,  But the code is not working. Temp value is coming so incorrect and with - Values ( Like -29 C , -17 C )

 

static int on_adc1(int argc, char *argv[])

{

                float fVolts   = (1.2 / 268435456);      // Internal reference, calculate lsb size in volts

                float fVoltage = (adc1_result * fVolts);// Calculate ADC result in volts

                float internal_temperature = 25.0 - (((fVoltage * 1000.0) - 82.1) * 4.0);

 

pADI_ADC1->CON = (pADI_ADC1->CON & ~ADCCON_BUFBYPN_MSK & ~ADCCON_BUFBYPP_MSK & ~ADCCON_BUFPOWN_MSK & ~ADCCON_BUFPOWP_MSK & ~ADCCON_ADCCODE_MSK & ~ADCCON_ADCREF_MSK & ~ADCCON_ADCCN_MSK & ~ADCCON_ADCCP_MSK) | ADCCON_BUFBYPN | ADCCON_BUFBYPP | ADCCON_BUFPOWP | ADCCON_BUFPOWN | ADCCON_ADCCODE_INT | ADCCON_ADCREF_INTREF | ADCCON_ADCCN_TEMP | ADCCON_ADCCP_TEMP;

                pADI_ADC1->ADCCFG = (pADI_ADC1->ADCCFG & ~ADCCFG_EXTBUF_MSK) | ADCCFG_EXTBUF_OFF;

                pADI_ADC1->MDE = (pADI_ADC1->MDE & ~ADCMDE_PGA_MSK) | ADCMDE_PGA_G2;

                pADI_ADC1->MSKI = (pADI_ADC1->MSKI & ~ADC1MSKI_RDY_MSK) | ADCMSKI_RDY_EN;

 

                ADC1CON_ADCEN_BBA = true;

 

                return 0;

}

Please help us to fix this problem.

Regards...

Thread Notes