This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
Why when I sample sinusoid ADC numbers is repeated?
Hello Vadim,
I need a few more details to understand your issue. Can you provide your ADC setup code (or SysConfig setup if you're using that)? Also, how are you reading the results?
Thanks,
Ibukun
__interrupt void INT_myADC0_1_ISR(void)
{
//
// Add the latest result to the buffer
//
adcAResults[index++] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
//
// Set the bufferFull flag if the buffer is full
//
if(RESULTS_BUFFER_SIZE <= index)
{
index = 0;
bufferFull = 1;
}
//
// Clear the interrupt flag
//
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
Hi Ibukun,
Thanks for your support! The above is my ADC reading routine. how can I attached syscfg file?
thanks Vadim
Vadim,
You can just attach the .syscfg file in your project directory (or open it in a text editor and paste its contents). Is the ADC setup done entirely through SysConfig, or do you have C code that manipulates the SOC configurations?
Best regards,
Ibukun
Hi Ibukun,
I did it entirely through SysConfig,
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F2837xD" --package "F2837xD_337ZWT" --part "F2837xD_337ZWT" --context "CPU1" --product "C2000WARE@4.02.00.00"
* @versions {"tool":"1.15.0+2826"}
*/
/**
* Import the modules used in this configuration.
*/
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
const adc1 = adc.addInstance();
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
adc1.$name = "myADC0";
adc1.enabledSOCs = ["ADC_SOC_NUMBER0"];
adc1.soc0SampleWindow = 20;
adc1.enabledInts = ["ADC_INT_NUMBER1"];
adc1.enableInterrupt1 = true;
adc1.enableInterrupt1ContinuousMode = true;
adc1.registerInterrupts = ["1"];
adc1.soc0Trigger = "ADC_TRIGGER_EPWM2_SOCA";
adc1.adcInt1.enableInterrupt = true;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.$name = "myEPWM1_Input";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_PERIOD = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmCounterCompare_enableShadowLoadModeCMPA = false;
epwm1.epwmTimebase_period = 2199;
epwm1.epwmCounterCompare_cmpA = 1099;
epwm1.epwm.$assign = "EPWM1";
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.$name = "myEPWM2_ADC";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_PERIOD = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmCounterCompare_enableShadowLoadModeCMPA = false;
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_PERIOD = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmTimebase_period = 199;
epwm2.epwmCounterCompare_cmpA = 99;
epwm2.epwmEventTrigger_EPWM_SOC_A_triggerEnable = true;
epwm2.epwmEventTrigger_EPWM_SOC_A_triggerSource = "EPWM_SOC_TBCTR_U_CMPA";
epwm2.epwmEventTrigger_EPWM_SOC_A_triggerEventPrescalar = "1";
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "ball.A7";
epwm2.epwm.epwmbPin.$assign = "ball.B7";
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/
epwm1.epwm.epwmaPin.$suggestSolution = "ball.C8";
epwm1.epwm.epwmbPin.$suggestSolution = "ball.D8";
thanks Vadim
Hello Vadim,
I don't see the ADC clock pre-scale setting or the resolution/signal mode settings in the SysConfig pasted above.
For reference, assuming SYSCLK is 200MHz, the minimum ADC clock prescale must be divide-by-4.0 for this device.
It looks like you've configured both output A and output B on the EPWM to perform CMPA, which generates an SOC trigger. I think that is causing two SOC triggers to be issued for the same timebase period, which would result in back-to-back conversions on the same EPWM period, and would explain your results.
Best regards,
Ibukun