Part Number: TMS320F28377D
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE
Hi,
I have the following simple code which is not simple for me. Could you please help me understand and make it better?
1. For acqps setting, can I use one if statement which can include all ADCA to ADCD (I actually have the setting from ADCA to ADCD) ?
2. For one ADCA or other ADCX, is the following one interrupt setting enough? or do I need to add the three ? mark setting after ADCA SOC0 setting?
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //EOC_X will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
3. Do I need to set this ( is this the default setting)? AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 15; // SOC0 is high priority.
4. The trigger source is ePWM1, what if ePWM3 is not setting or is on off state? what does the ADC value look like, zero or not allowed? In my settings, some are triggered by ePWM1, some are triggered by ePWM7. When ePWM1 is on, ePWM7 is off or vice versa, can I do the setting together or I have to set it separately?
5. ADCa_soc0, ADCb_soc0, ADCc_soc0 and ADCd_soc0 are processed simultaneously, then all ADCx_soc1, ---15? If so, can I just set one interrupt for all by choosing the largest socx as the trigger source?
6. Is any of SEL1N2 or SEL3N4 fine to choose?
Thanks for your help,
Hongmei
----------------------------------------------------------------------------------------------------------------------
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14;
}
else {
acqps = 63;
}
EALLOW;
{
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0;
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;
AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 15; // SOC0 is high priority
}
? AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //EOC_X will set INT1 flag
? AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
? AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
{
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1;
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps;
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 5 ;
}
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //EOC_X will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;
//------------------------------------------------------------------------
if(ADC_RESOLUTION_12BIT == AdcbRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14;
}
else {
acqps = 63;
}
EALLOW;
// if (1 <= ADC_B_SAMPLING_NUMBER_ISR1)
{
AdcbRegs.ADCSOC0CTL.bit.CHSEL = ADC_B_SAMPLING_CH1_ISR1;
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps;
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 5;
}
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC0 will set INT1 flag
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;
--------------------------------------------------------------------------------------------------------------------------------------