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.

Piccolo F28027: Changing Control Register settings in interrupt loop

When using the comparator, I am trying to toggle the ePWM1A output; I am aware that the comparator can be initialized to either force ePWM1A high OR low, but not toggle.

The first question is, can ePWM1A output be toggled?

I wrote code which compiles and loads OK without warnings, but which doesn't appear to work.

Generally, I am initializing the peripherals, entering an infinite while loop, and allowing the ePWM to establish the interrupt. Below is the code for my interrupt loop; note that I use "flag" as a state variable. Also, without the if/else statement, the operation of the comparator/ePWM is fine.

Does anyone see anything that I've done wrong? Could it be that initialization takes so much time that it is impractical to change it in an interrupt loop (which has a 10 microsecond sampling rate)?

void isr_int3pie1_task_fcn(void)
{
   EALLOW;  
   if(flag == 0)
   {
    EPwm1Regs.TZCTL.bit.TZA = 2;
    EPwm1Regs.TZCTL.bit.DCAEVT2 = 2;
   }
   else
   {   
    EPwm1Regs.TZCTL.bit.TZA = 1;
    EPwm1Regs.TZCTL.bit.DCAEVT2 = 1;
   }
   EDIS;

   AdcRegs.ADCSOCFRC1.bit.SOC0 = 1;
   asm(" RPT #22 || NOP");
   ADC0 = (AdcResult.ADCRESULT0);
       
   Comp1Regs.DACVAL.bit.DACVAL = ADC0;
   flag = !flag;
     
}

  • Hi,

    I have few questions:

    1. is the Interrupt driven by EPWM1.

    If that is the case,  whether is it on rising edge or falling edge.

     

    2. You can measure the timing taken by the functions in the ISR by placing a GPIO output and check whether it is well within your required limits.

    3. You can as well check, whether yout code is working or not by just placing it in a while loop, instead of keeping it in an ISR. this will confirm whether the code is working or not.

    Once you get the code working and you get your time, you can check with the conflict in the ISR if any.

  • Yes, the interrupt is driven by EPWM1. It is configured to interrupt when the counter TBCTR = 0 (i.e., ETSEL_INTSEL = 1).

    Thank you for suggestions 2 and 3.