Hi, Robert,
In your code, you do not point out the ADC code which can not start ADC conversion.
I suppose that following code has issue:
for(;;)
{
StartTempConversion();
while(ConversionAComplete()==0){
}
.........................................
}
This is my opinion for the StartTempConversion() code:
void StartTempConversion()
{
//need to connect to the A chanel
ADC0_CFG2 = 0x0; //01111
//dissable differential mode
//clear the old reguiseter value and set it to the new value
ADC0_SC1A &= ~0xFFFFFFE0; //Rong:the line will start ADC conversion, pls delete it, because it also write the ADC0_SC1A register
//this shoud start the conversion
ADC0_SC1A |= 0x16 ; //Rong: change it to ADC0_SC1A = 0x16 ; without "|"
//ADC0_SC1(1)= (0<<5) | 0x16 | (1<<6);
//set the first 5 bits equal to the correct location
}
Pls have a try. BTW, pls pay attention the ADC clock frequency, based on data sheet, the ADC clock should be less than 18MHz, you use BUS clock, which can reach up to 60mhz for K21, pls check it yourself. In software triggering mode, the ADTRG bit in ADCx_SC2 should be cleared.
Hope it can help you
BR
Xiangjun Rong