Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
I want to use F28335 to control FOC control of PMSM with sine PWM and I want to configure ADC works as cascaded, sequential, and stop/start. So I use PWM as my interrupt source and I configure the ADC as follows. I was wondering the configuration of the ADC it correct?
void main(void)
{
InitAdc();
// Specific ADC setup for this project:
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 1 Cascaded mode
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conversions
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // Convert channel 0
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1; // Convert channel 1
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCTRL1.bit.CONT_RUN = 0; // Setup stop/start run
}
interrupt void epwm1_isr(void) {
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
AdcRegs.ADCTRL2.bit.INT_MOD_SEQ1=0;
while (AdcRegs.ADCST.bit.INT_SEQ1== 0)
{
}
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
SampleA0 =((AdcRegs.ADCRESULT0>>4)); //Saves the ADC A0 reading
SampleA1 =((AdcRegs.ADCRESULT1>>4)); //Saves the ADC A1 reading
}