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.

CCS/LAUNCHXL-F28027: How can i make a 1Hz, 2Hz, 3Hz PWMs ?

Part Number: LAUNCHXL-F28027
Other Parts Discussed in Thread: LAUNCHXL-F28379D

Tool/software: Code Composer Studio

Hello,

I am trying to make a 1Hz, 2Hz, 3Hz PWMs using PWM modules and with setting HSPCLKDIV = 7 and CLKDIV = 7, i.e 60MHz devided by /14 and /128.

I only succeeded to generate 1Hz frequancy but i couldn't generate the others ...so is there a way to devide the 60MHz freq like in LAUNCHXL-F28379D using EPWMCLKDIV.

  • Younes,

    there is not a EPWMCLKDIV on this device, you cannot divide the clock lower without affecting the frequency of SYSCLK. When generating signals this slow it may make sense to use a GPIO and a CPU timer.

    If you wish to still use the PWM you may be able to adjust the counter values within the ISR. This would require you to use 100% and 0% duty cycle, which may have some drawbacks. If you do decide to try this route I would recommend using Up-count mode. If you have troubles implementing this method please take a look at SPRAAI1

    Regards,
    Cody 

  • Younes,

    The best option might be to use the eCAP in APWM mode because the eCAP module has 32bit timers. This should enable you to reach the slower frequencies.

    Regards,
    Cody

  • Thanks Cody,

    I used the CPU Timer with GPIOs.

    just one little thing ...if i used GPIOs with "DELAY_US(1000 * 1000); //1 second delay", is it going to be that same as setting the Timer interrupts to 1 second "ConfigCpuTimer(&CpuTimer0, 60, 1000000);". I mean do they take the same amount of time !?

    Regards,
    Younes
  • Younes,

    Really the best way to do this would be through the eCAP module because it doesn't require SW intervention. But the method you used is perfectly valid as well.

    I suspect there will be a slight difference between those two methods, no more than a few cycles. Which at 1-4Hz will be negligible. I would recommend using the interrupt if possible.

    I have ranked the three solutions in order of best to worst below. I wouldn't recommend number 3 below because you will be stalling your CPU for long amounts of time. Some very simple applications could be OK with this delay though.

    1. eCAP APWM mode
    2. GPIO controlled inside of a CPU timer's interrupt
    3. GPIO controlled with CPU delays

    Regards,
    Cody