My question wss about F28069 on-chip temperature sensing.
I was able to create a simple code project to try out the temperature sensing only and got it working. However, when I added the temperature monitor code into a real project, I could not get the temperature but the physical signal on the pin ADC-A5, even though ADCCTL1.bit.TEMPCONV was set to 1.
I tested the code on both HVMotorCtrl+PfcKit and DRV8312EVM hardware, but ended up with the same problem. Below is my code of the ADC initialization. Please review and comment what was the issue.
void InitAdc(void)
{
EALLOW;
//reset ADC
AdcRegs.ADCCTL1.bit.RESET = 1;
//delay two cycle required before initialization
DelayUs(ADC_2usDELAY);
AdcRegs.ADCCTL1.bit.RESET = 0; //release reset
//power sequence: bandgap -> reference -> rest of ADC
AdcRegs.ADCCTL1.bit.ADCBGPWD = ADC_POWER_ON; // Power up band gap
DelayUs(ADC_10usDELAY); // Delay before powering up the rest of ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = ADC_REF_INT; // select internal bandgap for input voltage reference
AdcRegs.ADCCTL1.bit.ADCREFPWD = ADC_POWER_ON; // Power up reference
AdcRegs.ADCCTL1.bit.ADCPWDN = ADC_POWER_ON; // Power up rest of ADC
AdcRegs.ADCCTL1.bit.INTPULSEPOS = ADC_INT_CONV_END; //INT pulse generation occurs a cycle prior to ADC result latching to its register
AdcRegs.ADCCTL1.bit.TEMPCONV = ADC_TEMP_SENSOR_EN; //Temperature sensor is connected
AdcRegs.ADCCTL2.all = ADCREGS_ADCCTL2_INIT; //ADC clock configuration
//configure sample mode
AdcRegs.ADCSAMPLEMODE.all = 0xFF;
//SOC0/1
AdcRegs.ADCSOC0CTL.bit.CHSEL = ADC_CH_TSI; // Tach/Speed Analog Input TSI
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC0CTL.bit.ACQPS = ADCSOC_ACQPS_VOLT; // set acquisition width
//SOC2/3
AdcRegs.ADCSOC2CTL.bit.CHSEL = ADC_CH_MTR_IA_IB; // Motor Phase A/B IA-FB, IB-FB
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC2CTL.bit.ACQPS = ADCSOC_ACQPS_CURR; // set acquisition width
//SOC4/5
AdcRegs.ADCSOC4CTL.bit.CHSEL = ADC_CH_MTR_I_VBUS; // Motor bus current and voltage
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC4CTL.bit.ACQPS = ADCSOC_ACQPS_CURR; // set acquisition width
//SOC6/7
AdcRegs.ADCSOC6CTL.bit.CHSEL = ADC_CH_MTR_IC_IA; // Motor bus current IC-FB
AdcRegs.ADCSOC6CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC6CTL.bit.ACQPS = ADCSOC_ACQPS_CURR; // set acquisition width
//SOC8/9
AdcRegs.ADCSOC8CTL.bit.CHSEL = ADC_CH_Vhb3; // Motor drive H bridge 3
AdcRegs.ADCSOC8CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC8CTL.bit.ACQPS = ADCSOC_ACQPS_VOLT; // set acquisition width
//SOC10/11
AdcRegs.ADCSOC10CTL.bit.CHSEL = ADC_CH_TEMP_IB; // MCU temperature and motor phase current IB
AdcRegs.ADCSOC10CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC10CTL.bit.ACQPS = ADCSOC_ACQPS_CURR; // set acquisition width
//SOC12/13
AdcRegs.ADCSOC12CTL.bit.CHSEL = ADC_CH_RSVD; // reserved
AdcRegs.ADCSOC12CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC12CTL.bit.ACQPS = ADCSOC_ACQPS_VOLT; // set acquisition width
//SOC14/15
AdcRegs.ADCSOC14CTL.bit.CHSEL = ADC_CH_MTR_VHB2; // Motor voltage H-bridge ADC-Vhb2, ADC-Vhb1
AdcRegs.ADCSOC14CTL.bit.TRIGSEL = ADCTRIG_EPWM1SOCA; // select EPWM1SOCA as SOC triggering source
AdcRegs.ADCSOC14CTL.bit.ACQPS = ADCSOC_ACQPS_VOLT; // set acquisition width
...
//Enable ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = ADC_ENABLE;
EDIS;
}