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.

Generate PWM c5502



Hi,

I´m trying to generate a PWm signal with C5502 using Timer0 but it is not working for small periods, such as <2ms. I seems to be a conflit with MCBSP DMA RX interrupt because when I disable it, the signal is generated as I configured it.

Could anybody uses another way to generate a PWM signal on this DSP? The period I need is smaller then 10ms.

Thanks

Ana Leticia

  • The period is only part of the story. What is the smallest pulse that you need (in percent or ms), and how fine do you need the resolution? By resolution, I assume that you may need to vary the pulse width, so I am asking how many steps you might need, or how small an increment you might need when changing the pulse width.

  • I need to generate a PWM signal with a resolution of 600 steps with a period of 10ms. So the minimum ON time is 16.66us.

    The last try I get was to configure timer0 reload period to achieve the ON time and after that the OFF time, but when I enable MCBSP channel, the time is bigger than I configure. I think that timer0 ISR is not called during MCBSP DMA isr. I´m not understanding is that timer0 has higher priority than MCBSP / DMA channel.

    Could anyone give me a hint what could I check to verify interrupt priority?

    Thanks

     

     

  • Looks like you're using interrupt service routines to update the signal by interrupting twice per period. Even if you get the interrupt priority straight, I think the result would still have a lot of jitter.

    I believe that the Timer can be programmed to generate your pulse without further software interaction, which should be highly reliable. Look at page 1-17 of SPRU595C where an example is given for an even higher frequency than yours.  PWID would set your pulse width in clock cycles (I don't know what your CPU clock speed is, so I can't say what the exact value should be).  You'll also have to calculate a value for PRD which matches your 100 Hz cycle, although you may need a high TDDR prescaler to get that low. Don't forget to set ARB for auto-reload of the Timer, and then it will continue to generate your PWM signal on the TIN/TOUT pin. Only when you change the pulse step would you need to change any timer registers.

    Sorry for providing only a quick and dirty response, but you might be able to get this running by replacing your interrupt routine with an auto-load pulse timer setup.

  • Hi Brian, thanks for your reply.

    Yes, i´m using interrupt to generate the signal. I look SPRU595C but I understand that with timer output  mode  onlye generates limited puldes wide (1,2,4 or 8 CPU clock) by changing PWID. Do you know if I understand it right? The another output mode CLOCK mode generates a 50% PWM signal.  

    So, I´m not happy about this simple feature that C5502 doens´t have: a single PWM signal generate mode.

    I´m studing another way to do that, but with MCBSP, UART and Timer1 function together, is not a easy task to be done.

    Ana Leticia     

  • You are correct, PWID only offers 4 choices (2 bit code).  I did not notice that limitation.

    I hate to recommend other processors in a Texas Instruments forum, but the Microchip PIC family has ample support for PWM.  Some chips can generate 2 or more different PWM signals at the same time.

    If you are stuck with the C5502, then you might consider using a DMA channel to copy from a prepared memory buffer to a GPIO port.  You could set the period by controlling the length of the DMA transfer, and you could set the Pulse Width by altering the data in memory.  Actually, with DMA, you could create any arbitrary pattern, not just simple PWM.

    The reason I recommend DMA is that interrupts will have latency and there will always be processes with higher priority.  For that matter, even the DMA suffers from potential latency if other DMA channels or memory operations cause the channel to be busy, but those delays are much shorter than interrupt latency.

  • Brian Willoughby said:

    I hate to recommend other processors in a Texas Instruments forum, but the Microchip PIC family has ample support for PWM.  Some chips can generate 2 or more different PWM signals at the same time.

    Yes, there are alternatives out there that do offer true PWM functionality, including the one mentioned.

    However, I submit that there are many options available from TI that offer PWM functionality as well, including the MSP430, C2000 and Stellaris family of Microcontrollers.

     

     

  • Thansk... I already use MSP430 but my board is ready and I don´t have avaible time to add another IC on it.

    Thanks

     

  • I´ve tought about this solution: use a DMA channel to generate a pattern on a GPIO pin.

    I will try it.

    Thanks