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.

TMS570LS1224: Triggering ADC from ETPWM, with ADC notification

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hello everyone.

Has anyone had experience with starting ADC conversion from PWM events?

I'm trying to implement a PWM current control where the eTPWM triggers ADC conversions on ADC1 EVENT group, but the adc notification is not happening. I have had no problem triggering an eTPWM period notification directly, or directly starting an ADC conversion from software and getting an adc notification. I'm working in HalCoGen and I've enabled the VIM channel for ADC1Event. Here is a screenshot of my eTPWM and ADC settings:

I have tried both rising edge and falling edge on the trigger.

Here's the code from my sys_main.c:

/* USER CODE BEGIN (3) */
etpwmInit();
adcInit();

adcEnableNotification(adcREG1, adcGROUP0);
_enable_IRQ();

etpwmStartTBCLK();

while(1) {

}
/* USER CODE END */

I've attached my project files as well.

Any ideas?4024.mypwm.zip

  • Hello Eric,

    From your HALCoGen project attached, the pinmux for etPWM is not set. Did you modify the pinmux settings 9pinmux.c) manually?
  • Hi QJ,

    I haven't done any pinmux settings manually. In the pinmux tab of HalCoGen, the pinmux for etPWM is enabled but do I need to do anything else?

  • Hi Eric,

    This is my test case to trigger ADC sampling using PWM (from etPWM1B) falling edge:
    Please call : adcStartConversion(adcREG1, adcGROUP0);

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    gioInit();
    adcInit();
    etpwmInit();

    /* Set the COS of ADC module*/
    /* This bit affects emulation operation only. It defines whether the ADC core clock (ADCLK) is immediately halted when the CPU enters
    * debug mode or if it should continue operating normally.*/

    /* ADC module continues all ongoing conversions as per the configurations of the three conversion groups.*/
    adcREG1->OPMODECR |= (0x1 << 24);

    /* Configure epwm time-base counter keeps running in emulation mode */
    etpwmREG1->TBCTL |= (0x2 << 14);

    /* Enable RTI Compare 0 interrupt notification */
    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

    _enable_IRQ();

    etpwmStartTBCLK();

    adcEnableNotification(adcREG1, adcGROUP0);
    adcStartConversion(adcREG1, adcGROUP0);

    while(1);
    /* USER CODE END */

    return 0;
    }

    /* USER CODE BEGIN (4) */
    void adcNotification(adcBASE_t *adc, uint32 group)
    {
    adcData_t data; //for channel 8
    uint16 cmpA;

    count = adcGetData(adcREG1, adcGROUP0, &data);
    adcValue_ch8[num] = data.value;

    //change the duty cycle of epwm2_A
    cmpA = (etpwmREG2->TBPRD * adcValue_ch8[num])/0xFFF;
    etpwmSetCmpA(etpwmREG2, cmpA);
    }