Dear forum members,
I am using ADC to read current value and convert to temperature.
unsigned long ulTemp_ValueC;
uint32_t ulADC0_Value;
uint32_t TEMP = 0;
void CTI_CONFIG_TEMPSENSOR()
{
// The ADC0 peripheral must be enabled for use.
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
// Enable sample sequence 3 with a processor signal trigger.
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
// Configure step 0 on sequence 3. Sample the temperature sensor
// (ADC_CTL_TS) and configure the interrupt flag (ADC_CTL_IE) to be set
// when the sample is done. Tell the ADC logic that this is the last
// conversion on sequence 3 (ADC_CTL_END).
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
// Sample sequence 3 enable
ADCSequenceEnable(ADC0_BASE, 3);
// Clear the interrupt status flag
ADCIntClear(ADC0_BASE, 3);
}
unsigned long CTI_READ_TEMPSENSOR(void)
{
// Trigger the ADC conversion
ADCProcessorTrigger(ADC0_BASE, 3);
// Wait for conversion to be completed.
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
// Read ADC Value.
ADCSequenceDataGet(ADC0_BASE, 3, &ulADC0_Value);
//TEMP = (147.5 - ((187.5 × ulADC0_Value) / 4096));
return(TEMP);
}
Any body please can validate my code....I dont have much idea about ADC operation.......
Regards,
Krishnan