Other Parts Discussed in Thread: C2000WARE
Tool/software: TI C/C++ Compiler
Not sure if this is a bug with the C preprocessor, or just with Driverlib.
I imported the adc_ex2_soc_epwm example program from C2000ware 1.03 and was experimenting with it. (Using Code Composer 7.3).
At the top of the adc_ex2_soc_epwm.c file I changed:
// // Defines // #define RESULTS_BUFFER_SIZE 256 //#define EX_ADC_RESOLUTION ADC_RESOLUTION_12BIT // Or ADC_RESOLUTION_16BIT //#define EX_ADC_SIGNAL_MODE ADC_MODE_SINGLE_ENDED // Or ADC_MODE_DIFFERENTIAL #define EX_ADC_RESOLUTION ADC_RESOLUTION_16BIT #define EX_ADC_SIGNAL_MODE ADC_MODE_DIFFERENTIAL
and ran the example and at first glance it appeared to work. I watched in the debugger and ADC_setMode() definately set the ADC to 16bit differential mode.
however I was thrown off by initADCSOC(). In the editor it seemed to still gray out the changes for the ADC_RESOLUTION_16BIT like I expected. To confirm it wasn't being executed I tweaked the code to be:
//
// Function to configure ADCA's SOC0 to be triggered by ePWM1.
//
void initADCSOC(void)
{
//
// Configure SOC0 of ADCA to convert pin A0. The EPWM1SOCA signal will be
// the trigger.
//
// For 12-bit resolution, a sampling window of 15 (75 ns at a 200MHz
// SYSCLK rate) will be used. For 16-bit resolution, a sampling window of
// 64 (320 ns at a 200MHz SYSCLK rate) will be used.
//
#if(EX_ADC_RESOLUTION==ADC_RESOLUTION_12BIT)
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN0, 15);
#elif(EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT)
bug;
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN0, 64);
#endif
//
// Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make
// sure its flag is cleared.
//
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
And it still compiled fine!!! (bug didn't cause the error). I am not sure if the problem is the #if() statement is malformed, or if CPP is choking on the fact that ADC_RESOLUTION_16BIT is an enumerated type.