Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hello,
I'd like to explain the issue I'm facing.
In the initial version of the program (shown below), everything works fine. I’m using 4 ADCs: first, I wait for their synchronization, then I perform several conversions using only SOC0. Note that some ADC initializations are handled in a separate function.
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin A2 on ADC-A
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin B2 on ADC-B
AdccRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin C2 on ADC-C
AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin D0 on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-D
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-A
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-B
AdccRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-C
AdcdRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-D
EDIS;
CoefTableExc = SINE_TAB_SIZE_MAX / sine_tab_size;
AdcaRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-A - Start of conversion
AdcbRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-B - Start of conversion
AdccRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-C - Start of conversion
AdcdRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-D - Start of conversion
//wait for ADC-A to complete, then acknowledge flag
//
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-A int
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-B int
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-C int
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-D int
*********************************************************************************
Index = 0;
for (SineIndex = 0; SineIndex < (SINE_NB + FreeSineNb); SineIndex ++)
{
for (SineTableIndex = 0; SineTableIndex < sine_tab_size ; SineTableIndex ++)
{
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-A to complete
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-B to complete
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-C to complete
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-D to complete
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
if( SineIndex >= FreeSineNb )
{
IndexRecord = (int)(Index / (sine_tab_size / SINE_TAB_SIZE));
BBuffer_S1[IndexRecord] = AdcaResultRegs.ADCRESULT0;
switch (FeedBackAcq)
{
case 0:
Buffer_S2[IndexRecord] = AdcbResultRegs.ADCRESULT0;
break;
case 1:
Buffer_S3[IndexRecord] = AdccResultRegs.ADCRESULT0;
break;
case 2:
Buffer_S4[IndexRecord] = AdcdResultRegs.ADCRESULT0;
break;
}
Index++;
}
}
}
Next, I want to utilize both SOC0 and SOC1 on ADC-A. However, in the first version of the program, execution halts at the following line:
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin A2 on ADC-A
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3; // SOC1 will convert pin A3 on ADC-A
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin B2 on ADC-B
AdccRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin C2 on ADC-C
AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin D0 on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; // End of SOC1 will set INT1 flag on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-D
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-A
AdcaRegs.ADCSOC1CTL.bit.ACQPS = 231; // SOC1 will use sample duration of 231 SYSCLK cycles on ADC-A
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-B
AdccRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-C
AdcdRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-D
EDIS;
CoefTableExc = SINE_TAB_SIZE_MAX / sine_tab_size;
AdcaRegs.ADCSOCFRC1.all = 0x0003; // SOC0 and SOC1 are used on ADC-A - Start of conversion
AdcbRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-B - Start of conversion
AdccRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-C - Start of conversion
AdcdRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-D - Start of conversion
//wait for ADC-A to complete, then acknowledge flag
//
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-A int
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-B int
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-C int
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-D int
*********************************************************************************
Index = 0;
for (SineIndex = 0; SineIndex < (SINE_NB + FreeSineNb); SineIndex ++)
{
for (SineTableIndex = 0; SineTableIndex < sine_tab_size ; SineTableIndex ++)
{
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-A to complete
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-B to complete
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-C to complete
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-D to complete
// Program stops above on the first conversion //
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
if( SineIndex >= FreeSineNb )
{
IndexRecord = (int)(Index / (sine_tab_size / SINE_TAB_SIZE));
Buffer_S1[IndexRecord] = AdcaResultRegs.ADCRESULT0;
Buffer_S5[IndexRecord] = AdcaResultRegs.ADCRESULT1;
switch (FeedBackAcq)
{
case 0:
Buffer_S2[IndexRecord] = AdcbResultRegs.ADCRESULT0;
break;
case 1:
Buffer_S3[IndexRecord] = AdccResultRegs.ADCRESULT0;
break;
case 2:
Buffer_S4[IndexRecord] = AdcdResultRegs.ADCRESULT0;
break;
}
Index++;
}
}
}In the second version of the program, if I remove the flag acknowledgment after conversion, the program doesn’t stop. However, I’m uncertain if this behavior is correct.
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin A2 on ADC-A
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3; // SOC1 will convert pin A3 on ADC-A
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin B2 on ADC-B
AdccRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin C2 on ADC-C
AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin D0 on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; // End of SOC1 will set INT1 flag on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-D
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-A
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-B
AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-C
AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled on ADC-D
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-A
AdcaRegs.ADCSOC1CTL.bit.ACQPS = 231; // SOC1 will use sample duration of 231 SYSCLK cycles on ADC-A
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-B
AdccRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-C
AdcdRegs.ADCSOC0CTL.bit.ACQPS = 231; // SOC0 will use sample duration of 231 SYSCLK cycles on ADC-D
EDIS;
CoefTableExc = SINE_TAB_SIZE_MAX / sine_tab_size;
AdcaRegs.ADCSOCFRC1.all = 0x0003; // SOC0 and SOC1 are used on ADC-A - Start of conversion
AdcbRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-B - Start of conversion
AdccRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-C - Start of conversion
AdcdRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-D - Start of conversion
//wait for ADC-A to complete, then acknowledge flag
//
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-A int
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-B int
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-C int
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Synchro on ADC-D int
*********************************************************************************
Index = 0;
for (SineIndex = 0; SineIndex < (SINE_NB + FreeSineNb); SineIndex ++)
{
for (SineTableIndex = 0; SineTableIndex < sine_tab_size ; SineTableIndex ++)
{
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-A to complete
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-B to complete
while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-C to complete
while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); // Wait for ADC-D to complete
// If I remove ADCs acknowledge, program doesn't stop above on the first conversion
/*
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-A
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-B
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-C
AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Acknowledge flag on ADC-D
*/
if( SineIndex >= FreeSineNb )
{
IndexRecord = (int)(Index / (sine_tab_size / SINE_TAB_SIZE));
Buffer_S1[IndexRecord] = AdcaResultRegs.ADCRESULT0;
Buffer_S5[IndexRecord] = AdcaResultRegs.ADCRESULT1;
switch (FeedBackAcq)
{
case 0:
Buffer_S2[IndexRecord] = AdcbResultRegs.ADCRESULT0;
break;
case 1:
Buffer_S3[IndexRecord] = AdccResultRegs.ADCRESULT0;
break;
case 2:
Buffer_S4[IndexRecord] = AdcdResultRegs.ADCRESULT0;
break;
}
Index++;
}
}
}Do you have any suggestions to help me understand? How can it work if I never acknowledge the flag?
In another part of my program, I use ADC conversion with two SOCs, but I don't encounter this issue there.
EALLOW; // Use 2 SOCs for Port D AdcaRegs.ADCSOC0CTL.bit.CHSEL = 4; // SOC0 will convert pin A4 on ADC-A AdccRegs.ADCSOC0CTL.bit.CHSEL = 4; // SOC0 will convert pin C2 on ADC-C AdcdRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert pin D2 on ADC-D AdcdRegs.ADCSOC1CTL.bit.CHSEL = 4; // SOC1 will convert pin D4 on ADC-D AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled AdcaRegs.ADCINTFLGCLR.all = 0x0001; // Clears ADCINT1 flag bit on ADC-A AdccRegs.ADCINTFLGCLR.all = 0x0001; // Clears ADCINT1 flag bit on ADC-C AdcdRegs.ADCINTFLGCLR.all = 0x0001; // Clears ADCINT1 flag bit on ADC-D AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-A AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag on ADC-C AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 1; // End of SOC1 will set INT1 flag on ADC-D EDIS; AdcaRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-A - Start of conversion AdccRegs.ADCSOCFRC1.all = 0x0001; // SOC0 is used on ADC-C - Start of conversion AdcdRegs.ADCSOCFRC1.all = 0x0003; // SOC0 and SOC1 are used on ADC-D - Start of conversion //wait for ADCA to complete, then acknowledge flag // while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0); AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //wait for ADCC to complete, then acknowledge flag // while(AdccRegs.ADCINTFLG.bit.ADCINT1 == 0); AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //wait for ADCD to complete, then acknowledge flag // while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // //disable ADCINT1 flags on all ADCs to stop SamplingPeriod // EALLOW; AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0; AdccRegs.ADCINTSEL1N2.bit.INT1E = 0; AdcdRegs.ADCINTSEL1N2.bit.INT1E = 0; EDIS; // data processing ...
Thank you for your support.
