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.

MSP430 PWM

Hello all,

I want to apply a MSP430 device with the ability of generating and measuring PWM signals. In the selection tool there is no MSP430 with PWM channels.

So is there definitively no possibity to realize my application with a MSP340? In this case, which device would you recommend me?

Thanks! 

  • PWM capability is provided by the Timers - look in the appropriate Family User's Guide for details; eg,

     

    MSP430x2xx Family User's Guide (Rev. I) said:

    12.1 Timer_A Introduction

    Timer_A is a 16-bit timer/counter with three capture/compare registers. Timer_A can support multiple capture/compares, PWM outputs, and interval timing. Timer_A also has extensive interrupt capabilities.

    Interrupts may be generated from the counter on overflow conditions and from each of the capture/compare registers.

    http://www.ti.com/lit/ug/slau144i/slau144i.pdf

     

  • Hi Andy,

    thank you for your reply. I checked the MSP430x5xx series. It seems it can only generate PWM signals with the timers, but not measure it. So I want to use an interrupt pin to register the rising and falling edges and then save the value of counter in variable to calculate the duty circles.

    This software solution maybe more complicated then the hardware solution. But I have the instruction of applying a MSP430 for generating and measuring the PWM signals. Would this work? Which MSP430 interrupt pin can register both rising and falling edge, or can I use two interrupt pins?

    Thanks!

     

  • Yue Zhang said:
    I checked the MSP430x5xx series. It seems it can only generate PWM signals with the timers, but not measure it. So I want to use an interrupt pin to register the rising and falling edges and then save the value of counter in variable to calculate the duty circles.

    Yes, that's how it is done. There is no hardware to directly get the duty cycle of an incoming signal.

    Yue Zhang said:
    Which MSP430 interrupt pin can register both rising and falling edge, or can I use two interrupt pins?

    The CCR units of a tiemr can directly capture the current tiemr count on rising, falling or both edges. You'll need a timer and its CCR= and one of the othe rCCR registers for generating the PWM and two CCR registers to capture rising and falling edges of a signal. Same or differnt timer (the 5x series has more than one).
    Using two CCRs for independent capture of falling and rising edge is better, as it allows you to detect even small pulses that are smaller than your ISR latency. YOu can connect the signal to both CCRs input pins.
    To detect 0% or 100% DC (which won't trigger an edge), you can use the timer overflow interrupt. If it happens twice without a capture in-between, DC is 0% or 100% (check the CCRs input bit to decide which of them).

    Reliable PWM detection is only possible if the incoming PWM frequency is higher than the timer cycle frequency.

  • Hi Jens,

    thank you very much for your last answer. You said:

    Jens-Michael Gross said:

    You'll need a timer and its CCR= and one of the other CCR registers for generating the PWM and two CCR registers to capture rising and falling edges of a signal. Same or differnt timer (the 5x series has more than one).

     

    So as you said, a timer has several CCR registers. If I need two to generate the PWM signal, from which pin or from which register will the generated PWM signal come out then? 

     Thanks a lot!

     

  • "CCR=" -> "CCR0".

    The CCR0 register is used to set the PWM frequency. It limits the counting range of the timer (in up mode, the timer will count form 0 to CCR0).
    The PWM signal is then generated with CCR1 and its output pin (e.g. TA0.1 for TimerA0 on devices with more than one TimerA, also named TA1 on devices with just one TimerA)
    The CCR1 register will then set the duty cycle (depending on outmode, the output is set or reset on tierm overflow and reset ot seet when the timer reaches CCR1 value)

**Attention** This is a public forum