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.

2803x PWM: Disabling pwmA



How to reset all the 6 PWM signals to 0V with single command?

Which flag/register to set to achieve this? It is for protection.

Cheers

Joy

  • How about configuring the PWMs of interest to the same trip-zone (TZ), and then you can force the trip via software using the TZFRC register.

    Frankly, if this is for "protection" as you say, then a software approach is no good.  If you're thinking you will take an interrupt and then shut the PWM off using software, you cannot rely on this.  Suppose the interrupt is masked (disabled) for example.  Normally people will use the trip zone pin, and connect it to some external trip source such as an overcurrent sensor.

    Regards,

    David

  • Thanks for the reply. Can you please check the code below. Now I am not able to get PWM at all.

     EALLOW;
     EPwm1Regs.TZCLR.bit.OST = 1;
     EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO;
     EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO;
     EPwm1Regs.TZCLR.bit.OST = 0;
     EDIS;

    ------

    ------

    PWM_INIT_MACRO(1,2,3,pwm1);

    to trip PWM:

    EALLOW;
     EPwm1Regs.TZFRC.bit.OST = 1; // software trip genrated
    EDIS;

    And to enable again..

    EALLOW;
    EPwm1Regs.TZCLR.bit.OST = 1; // Clear Trip bit.
    EPwm1Regs.TZFRC.bit.OST = 0; // Clear for next forced trip.
    EDIS;


    Can you please see what is wrong in the disable/ enable part?


    Cheers

    Joy

  • Joy,

    I think the problem is you need to configure the ePWM1Regs.TZSEL register.  Another thing I see in your code is you are writing a 0 to TZCLR.bit.OST and a 0 to TZFRC.bit.OST.  This does nothing.  Only writing a 1 has any affect for these bits.

    I whipped up some quick test code using a PWM example I already had.  I just had to add the TZ stuff.  My example only used ePWM1A (not 1B), and I used TZ1 in OST mode to force the pin low.  In my main(), I forced a trip, followed by a trip clear.  I can see it working correctly on the scope (PWM running, then it stops when the trip is forced, then it starts again when the trip is cleared).

    Init code is:

    asm(" EALLOW");                  // Enable EALLOW protected register access
    EPwm1Regs.TZCTL.bit.TZA = 0x2;   // Trip action set to force-low for output A
    EPwm1Regs.TZSEL.bit.OSHT1 = 0x1; // TZ1 configured for OSHT trip of ePWM1
    EPwm1Regs.TZCLR.bit.OST = 0x1;   // Clear OST flag just in case
    asm(" EDIS");                    // Disable EALLOW protected register access

    and main loop code is:

    while(1)
    {
      asm(" EALLOW");                // Enable EALLOW protected register access
      EPwm1Regs.TZFRC.bit.OST = 0x1; // Force a OST trip for ePWM1
      asm(" EDIS");                  // Disable EALLOW protected register access

      asm(" EALLOW");                // Enable EALLOW protected register access
      EPwm1Regs.TZCLR.bit.OST = 0x1; // Clear the OST trip for ePWM1
      asm(" EDIS");                  // Disable EALLOW protected register access

    }

    I have attached the entire CCSv5.3.0 project.  Note that there is some other junk going on in this code.  ADC is configured and triggered from ePWM2.  Just ignor that.  Look at ePWM1 setup in EPwm.c, and main loop in main_nonBIOS.c.

    Regards,

    David

     

     

    F28335_TripZone_nonBIOS_ram.zip
  • Thank you very much Mr.David.

    It is worked for me.

    Thanks

    Joy