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.
Tool/software: TI C/C++ Compiler
Hello,
I am trying to setup an ADC to trigger of a EPWM, EPWM1A in particular.
I have confirmed the EPWM is working as intended.
However I cannot get any values from the ADC, I Have tried both example codes for SOC setup for EPWM trigger as well as just forcing the SOC.
Both times the read only gives back 132
Forcing gives the desired interrupt result and I am sent to the HWI I set up. However I cannot seem to get any reads from the ADCs. I am current using ADCAIN0 and it's just connected directly to 3.3V
Here is the instantiation code for the ADC
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_1_0); ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT,ADC_MODE_SINGLE_ENDED); ADC_setupSOC(ADCA_BASE,ADC_SOC_NUMBER0,ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0,19); ADC_setInterruptSOCTrigger(ADCA_BASE,ADC_SOC_NUMBER0,ADC_INT_SOC_TRIGGER_ADCINT1); //ADC_setSOCPriority(ADCA_BASE, ADC_PRI_ALL_ROUND_ROBIN); ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV); ADC_enableConverter(ADCA_BASE); DEVICE_DELAY_US(1000); EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A); EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO); EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A); EPWM_setADCTriggerEventPrescale(ADCA_BASE, EPWM_SOC_A, 1); ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0); ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1); ADC_enablePPBEventInterrupt(_base, ADC_PPB_NUMBER1,ADC_EVT_TRIPHI); ADC_setPPBTripLimits(_base, ADC_PPB_NUMBER1,_tripHiLimit, _tripLoLimit); ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
I see that the registers are written to.
I am unclear if I am missing something or perhaps the implementation order is incorrect.
I first setup the EPWM then I set up the ADC, both of them happen after this code in main, they are both instantiated in a task.
Device_initGPIO(); Device_enableAllPeripherals(); BIOS_start(); /* does not return */
Am I perhaps missing some additional setup.
Any help would be appreciated thanks
Hi Chris,
This:
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_1_0);
Is not going to work unless the SYSCLK of the device is 50MHz or less. Try it as /4 as in the examples.
Hello, I have modified the code to have ADC_CLK_DIV_4_0 instead of DIV_1
I am still experiencing the same issue, no interrupt occurs and every adc read returns 132.
I have the tasks set up to first instantiate the ADC and set the EPWM trigger disabled, then I instantiate the EPWM module.
I am assuming Channel 0 of ADCA corresponds to the pin ADCINA0 on the launchpad.
I am compiling the project as C++, But I have an identical project as C not working
These are what my registers look like if that helps
ADCCTL1 0x0084 ADC Control 1 Register [Memory Mapped]
ADCCTL2 0x0006 ADC Control 2 Register [Memory Mapped]
ADCBURSTCTL 0x0000 ADC Burst Control Register [Memory Mapped]
ADCINTFLG 0x0000 ADC Interrupt Flag Register [Memory Mapped]
ADCINTFLGCLR 0x0000 ADC Interrupt Flag Clear Register [Memory Mapped]
ADCINTOVF 0x0000 ADC Interrupt Overflow Register [Memory Mapped]
ADCINTOVFCLR 0x0000 ADC Interrupt Overflow Clear Register [Memory Mapped]
ADCINTSEL1N2 0x0020 ADC Interrupt 1 and 2 Selection Register [Memory Mapped]
ADCINTSEL3N4 0x0000 ADC Interrupt 3 and 4 Selection Register [Memory Mapped]
ADCSOCPRICTL 0x0200 ADC SOC Priority Control Register [Memory Mapped]
ADCINTSOCSEL1 0x0001 ADC Interrupt SOC Selection 1 Register [Memory Mapped]
ADCINTSOCSEL2 0x0000 ADC Interrupt SOC Selection 2 Register [Memory Mapped]
ADCSOCFLG1 0x0000 ADC SOC Flag 1 Register [Memory Mapped]
ADCSOCFRC1 0x0000 ADC SOC Force 1 Register [Memory Mapped]
ADCSOCOVF1 0x0000 ADC SOC Overflow 1 Register [Memory Mapped]
ADCSOCOVFCLR1 0x0000 ADC SOC Overflow Clear 1 Register [Memory Mapped]
ADCSOC0CTL 0x00500012 ADC SOC0 Control Register [Memory Mapped]
ADCSOC1CTL 0x00000000 ADC SOC1 Control Register [Memory Mapped]
ADCSOC2CTL 0x00000000 ADC SOC2 Control Register [Memory Mapped]
ADCSOC3CTL 0x00000000 ADC SOC3 Control Register [Memory Mapped]
ADCSOC4CTL 0x00000000 ADC SOC4 Control Register [Memory Mapped]
ADCSOC5CTL 0x00000000 ADC SOC5 Control Register [Memory Mapped]
ADCSOC6CTL 0x00000000 ADC SOC6 Control Register [Memory Mapped]
ADCSOC7CTL 0x00000000 ADC SOC7 Control Register [Memory Mapped]
ADCSOC8CTL 0x00000000 ADC SOC8 Control Register [Memory Mapped]
ADCSOC9CTL 0x00000000 ADC SOC9 Control Register [Memory Mapped]
ADCSOC10CTL 0x00000000 ADC SOC10 Control Register [Memory Mapped]
ADCSOC11CTL 0x00000000 ADC SOC11 Control Register [Memory Mapped]
ADCSOC12CTL 0x00000000 ADC SOC12 Control Register [Memory Mapped]
ADCSOC13CTL 0x00000000 ADC SOC13 Control Register [Memory Mapped]
ADCSOC14CTL 0x00000000 ADC SOC14 Control Register [Memory Mapped]
ADCSOC15CTL 0x00000000 ADC SOC15 Control Register [Memory Mapped]
ADCEVTSTAT 0x0000 ADC Event Status Register [Memory Mapped]
ADCEVTCLR 0x0000 ADC Event Clear Register [Memory Mapped]
ADCEVTSEL 0x0000 ADC Event Selection Register [Memory Mapped]
ADCEVTINTSEL 0x0000 ADC Event Interrupt Selection Register [Memory Mapped]
ADCCOUNTER 0x03D5 ADC Counter Register [Memory Mapped]
ADCREV 0x0004 ADC Revision Register [Memory Mapped]
ADCOFFTRIM 0x00FE ADC Offset Trim Register [Memory Mapped]
ADCPPB1CONFIG 0x0000 ADC PPB1 Config Register [Memory Mapped]
ADCPPB1STAMP 0x0000 ADC PPB1 Sample Delay Time Stamp Register [Memory Mapped]
ADCPPB1OFFCAL 0x0000 ADC PPB1 Offset Calibration Register [Memory Mapped]
ADCPPB1OFFREF 0x0000 ADC PPB1 Offset Reference Register [Memory Mapped]
ADCPPB1TRIPHI 0x00000000 ADC PPB1 Trip High Register [Memory Mapped]
ADCPPB1TRIPLO 0x00000000 ADC PPB1 Trip Low/Trigger Time Stamp Register [Memory Mapped]
ADCPPB2CONFIG 0x0000 ADC PPB2 Config Register [Memory Mapped]
ADCPPB2STAMP 0x0000 ADC PPB2 Sample Delay Time Stamp Register [Memory Mapped]
ADCPPB2OFFCAL 0x0000 ADC PPB2 Offset Calibration Register [Memory Mapped]
ADCPPB2OFFREF 0x0000 ADC PPB2 Offset Reference Register [Memory Mapped]
ADCPPB2TRIPHI 0x00000000 ADC PPB2 Trip High Register [Memory Mapped]
ADCPPB2TRIPLO 0x00000000 ADC PPB2 Trip Low/Trigger Time Stamp Register [Memory Mapped]
ADCPPB3CONFIG 0x0000 ADC PPB3 Config Register [Memory Mapped]
ADCPPB3STAMP 0x0000 ADC PPB3 Sample Delay Time Stamp Register [Memory Mapped]
ADCPPB3OFFCAL 0x0000 ADC PPB3 Offset Calibration Register [Memory Mapped]
ADCPPB3OFFREF 0x0000 ADC PPB3 Offset Reference Register [Memory Mapped]
ADCPPB3TRIPHI 0x00000000 ADC PPB3 Trip High Register [Memory Mapped]
ADCPPB3TRIPLO 0x00000000 ADC PPB3 Trip Low/Trigger Time Stamp Register [Memory Mapped]
ADCPPB4CONFIG 0x0000 ADC PPB4 Config Register [Memory Mapped]
ADCPPB4STAMP 0x0000 ADC PPB4 Sample Delay Time Stamp Register [Memory Mapped]
ADCPPB4OFFCAL 0x0000 ADC PPB4 Offset Calibration Register [Memory Mapped]
ADCPPB4OFFREF 0x0000 ADC PPB4 Offset Reference Register [Memory Mapped]
ADCPPB4TRIPHI 0x00000000 ADC PPB4 Trip High Register [Memory Mapped]
ADCPPB4TRIPLO 0x00000000 ADC PPB4 Trip Low/Trigger Time Stamp Register [Memory Mapped]
ADCINLTRIM1 0x09000000 ADC Linearity Trim 1 Register [Memory Mapped]
ADCINLTRIM2 0x0CF70000 ADC Linearity Trim 2 Register [Memory Mapped]
ADCINLTRIM3 0x04FE08FC ADC Linearity Trim 3 Register [Memory Mapped]
ADCINLTRIM4 0xFD020000 ADC Linearity Trim 4 Register [Memory Mapped]
ADCINLTRIM5 0x06FF0000 ADC Linearity Trim 5 Register [Memory Mapped]
ADCINLTRIM6 0x01FE01F8 ADC Linearity Trim 6 Register [Memory Mapped]
Hi Chris,
I'm not exactly sure where your error is. Since adc_ex2_soc_epwm driverlib example does exactly what you are trying to do (sample A0 via ePWM driven sampling) I'd strongly recommend running that code, unmodified, from the latest version of c2000ware. You should certainly get an ADC interrupt in that case. If your conversion results are not as expected, you can debug the HW setup until things work as expected. From there, you can incrementally make changes and re-test to get the code you need (e.g. change ePWM scheme, remove ADC-B, remove the #define options, etc.)