Hi all,
When i debug my program i found that ADC in 28335 is very strange.
This is my code in timer0 (with period is 250us)
unsigned int i;
// Reset ADC_value before read
ADC_value[0] = 0;
ADC_value[1] = 0;
ADC_value[2] = 0;
ADC_value[3] = 0;
ADC_value[4] = 0;
ADC_value[5] = 0;
ADC_value[6] = 0;
ADC_value[7] = 0;
// Start SEQ1 convert
AdcRegs.ADCTRL2.all = 0x2000;
// BP1
for (i = 0; i < 65; i++)
{
//BD2
while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
// Get ADC value
// Read AdcMirror.ADCRESULT register faster than AdcRegs.ADCRESULT
ADC_value[0] += (float)(AdcMirror.ADCRESULT0);
ADC_value[1] += (float)(AdcMirror.ADCRESULT1);
ADC_value[2] += (float)(AdcMirror.ADCRESULT2);
ADC_value[3] += (float)(AdcMirror.ADCRESULT3);
ADC_value[4] += (float)(AdcMirror.ADCRESULT4);
ADC_value[5] += (float)(AdcMirror.ADCRESULT5);
ADC_value[6] += (float)(AdcMirror.ADCRESULT6);
ADC_value[7] += (float)(AdcMirror.ADCRESULT7);
}
// Get average value
// BP3
ADC_value[0] = ADC_value[0] / 65;
ADC_value[1] = ADC_value[1] / 65;
ADC_value[2] = ADC_value[2] / 65;
ADC_value[3] = ADC_value[3] / 65;
ADC_value[4] = ADC_value[4] / 65;
ADC_value[5] = ADC_value[5] / 65;
ADC_value[6] = ADC_value[6] / 65;
ADC_value[7] = ADC_value[7] / 65;
At the first time, i put break point at BP1 and BP3, at DP1 timer0 value is 0x9200, press resume program stop at BP3 with timer0 value is 1A00 --> spent 0x7800 for for function. It is too long.
After that, i put only one break point at BP2 so i need press 65 times to run for function. when program run at BP3 timer0 value is 5400 --> spent 3E00 for for function and this value is match with my configuration for ADC module.
Why two values are different.
And in fact, my code run with value is 0x7800. Which this value, ADC module run too slow. Why is it.
Thanks for helping me.