Part Number: RF430FRL152H
Other Parts Discussed in Thread: REF2033
Tool/software: Code Composer Studio
Hi,
I used 12-bit ADC for measurement and got the ADC value as below.
But the ADC0 value is incorrect sometimes.
I use P1.0 to measure the time it takes to catch ADC0.
In the TRM, 12-bit ADC conversion time is 128ms. This is different from what I measured.
Does the following code have any setting error?
| ADC0 | Time (ms) | Result |
| 6186 | 31.62 | correct |
| 672 | 64.31 | incorrect |
| 671 | 64.3 | incorrect |
| 6180 | 31.62 | correct |
===========================================================
void SetupSD14(u08_t channel)
{
// setting: channel to be sampled, the programmable amplifier gain (2x), CIC filter, SD14INTDLY0 needed since CIC filter needs atleast two consecutive samples before producing an accurate result
// SDRATE at fastest result possible but also not the most accurate, also enabled is the SD14RBEN which is the current source into the thermistor and references resistor
//SD14CTL1 = SD14RBEN1 + SD14RBEN0 + SD14UNI + SD14GAIN0 + SD14INTDLY0 + channel;
SD14CTL1 = SD14UNI + SD14INTDLY0 + channel;
SD14CTL1 |= (channel == THERMISTOR_ADC2_CHANNEL) ? SD14RBEN1 : SD14RBEN0;
SD14CTL1 |= (channel == ADC0_CHANNEL) ? (SD14RATE1 + SD14RATE0) : SD14RATE1; // 12-bit
SD14CTL0 = SD14EN + VIRTGND; // SD14 module enabled,
SD14CTL0 |= SD14SC; // start the conversion
}
void main()
{
...
...
// Set and Read ADC0
SetupSD14(ADC0_CHANNEL);
// Setup P1.0 output
P1DIR |= 0x01;
// Toggle Output High/Low
P1OUT |= 0x01;
while(!(SD14CTL0 & SD14IFG)) {
};
P1OUT &= ~0x01;
nfc_sys_data.ADC0_Buffer[0] = SD14MEM0;
SD14CTL0 &= ~SD14IFG; // clear the data available interrupt
...
...
}
===========================================================
Thanks.