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.

TMS320F28335: TMS320F28335

Part Number: TMS320F28335


Hello Sir:

I used the ePWM module in my current project ; I have already realized the frequence and duty ratio ;

but I want to accurately control the number of send PWM pluses;

Is there any method to realize it?

Thanks!

  • Hi,

    Can you please provide more details on the requirement? What do you mean by send PWM pulses?

    Thanks
    Vasudha
  • Hi Vasudha:
    The requirement is that :
    for example, if I set the PWM frequence 100KHz,and duty ratio is 50%;I want to output accurately pluses number(for examle:15000-cycle pluses )
    what should i do?
    Thanks
    Flyer
  • Hi flyer,
    Let me know if my understanding is correct. As per requirement, the pwm signal should stop after 15000 cycle pulses. One approach for this could be to use one shot trip feature of trip-zone submodule. You can do a software force trip in a timer ISR after the required time.

    Thanks
    Vasudha
  • Hi Vasudha:
    I have tried the method you recommended;,but it seems doesn't work.
    for example:
    I set the PWM frequence 10KHz,duty ratio 50%; and open the 1ms ISR;
    in the 1ms timer ISR, I defined a temporary variable EPWM_cnt;
    when EPWM_cnt==1, I open the EPWM function ;
    and when EPWM_cnt==1000,I do a software force trip like you said;
    In theory,the EPWM execute 1 second, and will send 10000 pluses;but actually it send 9990 pluses;
    So what wrong with it ?

    Thanks
    Flyer
  • Hi Vasudha:
    Is there any progress with this problem?
    Looking forward to your reply.
    Thanks!
    Flyer.
  • Flyer,
    have you solved your issue yet?

    If not I suspect that you have a boundary condition error in your loop. If you are missing 10 pulses at 10 kHz that's equivalent to 1mS of delay, so instead delay from 0 to 1000 or 1 to 1001.

    Regards,
    Cody

  • Hi Cody:
    Thanks for your reply;
    The issue is not resolved; and I think it's not the reason you suspected;
    because I test different frequence;

    I set the PWM frequence 20Khz,in theory ,it will send 20000pluses;but actually it send 19960 pluses;
    I set the PWM frequence 50Khz,in theory ,it will send 50000pluses;but actually it send 49751 pluses;
    I set the PWM frequence 100Khz,in theory ,it will send 100000pluses;but actually it send 99009pluses;

    it seems have specific regularity.

    Thanks!
    Flyer
  • Flyer,

              the fact that adjusting the frequency does suggest that the problem is in the PWM not in the timer. Try subtracting 1 from your TBPRD value. Remember in the PWM zero counts as a TBPRD tick.

    If this doesn't solve your issue, what if your TBCLK in Hertz?

    Additionally, if your still having issues, lets begin debugging this as two issues.

    1. PWM frequency
      1. Let's verify the PWMs frequency, using a scope how many pulses do you see over 10 seconds.
    2. Timer length
      1. Toggle a GPIO just before and just after your delay timer, use an oscilloscope to verify the length of the delay.

    Regards,
    Cody 

  • Hi Cody:
    Thank you very much;
    Try subtracting 1 from your TBPRD value does solve my problem.

    Thanks!
    Flyer
  • Flyer,
    Great! If you have another question please start a new thread!

    Regards,
    Cody