Hello,
I am trying to add a new channel to my ADC polling. Adding this new channel to the FIFO breaks everything and I am unsure why. I am trying to measure the internal chip temperature if an I2C connected temperature sensor is not found.
When initializing my ADC I set my FIFO depth to 5 then add the 5 channels to read.
ADC_SetFifoDepth(ADC_FIFO_LEVEL5);
ADC_SetChannel(ADC_CHANNEL_AD10);
ADC_SetChannel(ADC_CHANNEL_AD13);
ADC_SetChannel(ADC_CHANNEL_AD5);
ADC_SetChannel(ADC_CHANNEL_AD14);
ADC_SetChannel(ADC_CHANNEL_TEMPERATURE);
If I add the first 4, or the last 1 it all works as expected. The issue is when I add them all together.
Before this step I check for the I2C temp sensor. If not found I read my Vbg to calculate Vdd as per AN3031.
if(!i2c_temp_sensor_found) {
I2C0_Disable();
ADC_EnablePCM_BG();
ADC_SetFifoDepth(ADC_FIFO_LEVEL2);
ADC_SetChannel(ADC_CHANNEL_BANDGAP);
ADC_SetChannel(ADC_CHANNEL_BANDGAP);
keazxx_temp_init();
ADC_SetFifoDepth(ADC_FIFO_DISABLE);
}
In keazxx_temp_init() I retrieve 2 samples from the FIFO. This should empty the FIFO. Periodically I set my FIFO channels to trigger a new conversion. My ADC IRQ runs as expected. Can anyone see any issues with my setup? Is my FIFO not being cleared correctly? Why when I add one more ADC point does everything go haywire?
Edit 1: I can confirm that my FIFO is empty at the end of my IRQ routine. I am not only reading some of my data. I am reading it all.
Edit 2: At the end of keazz_init_temp my FIFO is also empty.
Edit 3: I have set my FIFO to AND all compare registers. ADC_SC4 -> ACFSEL = 1 This has no effect.
Edit 4: I have confirmed that my FIFO is full when my ADC IRQ occurs and empty after I read the ADC->R register 5 times.
Edit 5: The issue has been resolved by setting the Long Sample Time Configuration. My only remaining question is how do I know which of the two slopes to use? When calculating the temp I am given two slops one for temps greater than 25 and one for temps less than 25. If I have not calculated the temp, how do I know which to use?
Hi, Michael
Hoping you are excellent.
I would like to know which AD channel are you using for the temperature sensor (ADC_CHANNEL_TEMPERATURE) ?
Also, please refer to this reference manual, in the section 3.8.1.4 page number 78-79 KEA128 Reference Manual.
Regarding your last question, about the slopes, you can read this thread, so it can be helpful: https://community.nxp.com/t5/Kinetis-Microcontrollers/On-chip-temperature-Calculations/m-p/465611
Please let me know if you have more questions.
Best Regards,
Pablo Avalos.