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.

MSP430G2231, does it really have 3 CCRs?

Other Parts Discussed in Thread: MSP430G2231

So I've got my little msp430g2231 on a launchpad, it's driving a single servo. I've followed this blog to achieve the necessary signal to drive the servo. To do this I use TACCR0 to control the frequency of my signal, and I use TACCR1 to control the duty cycle.

While reading the User Manual (as of 4/19/11 the most recent revision is H). I see in section 12.3 that there are 3 CCRx (CCR0-2). The TACCR2 related registers are annotated with the following: "Not present on MSP430x20xx device." Which I thought lucky, since this does not match the chip I am using.  I'd love to be able to drive 2 servos and make an x-y something or another. However reviewing the datasheet I see no mention of the CCR2 or an output for it. I see TA0.0 and TA0.1, but no TA0.2.

What did I miss? Is it possible to toggle 2 pins at different duty cycles using the same Timer_A without using interrupts with the msp430g2231? The user manual says there are 3 CCRs, the product search says there are 3 CCRs, the datasheet shows only 2 CCRs.

Let the forum begin!

Cheers,

  -Ken

  • Kenneth Sager said:
    The TACCR2 related registers are annotated with the following: "Not present on MSP430x20xx device."

    I guess they missed to add 'and every G2xxx device' (while this might be not true for future G devices).

    However, the G2231 datasheet clearly states that it has a Timer_A2 and not a Tiemr_A3. So there is no TACCR2. Sorry.

    Kenneth Sager said:
    Is it possible to toggle 2 pins at different duty cycles using the same Timer_A

    Yes. By using CCR0 for PWM output rather than controlling the PWM frequency. But then the only copntrol you have over the PWM frequency is the clocking frequency of the timer (runs in continuous mode then). It goves you ~15Hz per MHz timer clock (fTimer/65536).

  • Jen, thanks for the reply for a second there I was worried about slipping into limbo!

    Jens-Michael Gross said:
    However, the G2231 datasheet clearly states that it has a Timer_A2 and not a Tiemr_A3. So there is no TACCR2. Sorry.

    Certainly no need to be sorry,  it is most refreshing to have a little confirmation that I'm not crazy and there definitely are not 3 CCR. I anticipated the datasheet was the most correct document.

    Jens-Michael Gross said:
    Yes. By using CCR0 for PWM output rather than controlling the PWM frequency. But then the only copntrol you have over the PWM frequency is the clocking frequency of the timer (runs in continuous mode then). It goves you ~15Hz per MHz timer clock (fTimer/65536).

     This was certainly an option I had considered as well, but I'm not certain if i'll be able to generate the frequency I need and this is the second time I've ever used an msp430 so fancy things like changing clock frequencies is not in my repertoire (yet).

    Once more thanks again for the excellent reply, see you in the forums.

     

     

  • Kenneth Sager said:
    I'm not certain if i'll be able to generate the frequency I need

    The limit is 16MHz tiemr frequency and therefore 244Hz PWM cycle frequency then.

    Kenneth Sager said:
    fancy things like changing clock frequencies is not in my repertoire (yet)

    It's not that difficult. In fact it is th efirs tthing one should do: mastering the clock module and seting up a timer, for accurate timings. PWM is rather one of the next steps.

    However, most of the MSPs (not the low-pin.count, checp G series) have one or more TimerA with 3 or 5 CCR units, and many have also a TimerB with 7 CCR units. And TimerB can be trimmed to 12 or 8 bit count too, so you can reach higher PWM frequencies even if using its CCR0 for generating a PWM output.

    See ya.

  • I am trying to develop a solar charge controleer and load controller with MSP430G2231. I got MSP430 lauch pad with G2231 IC. I have generated PWM with TCCR0 as time period and TCCR1 as dutycycle. I want two PWM o/p with two different dutycycle. Is it possible to generate two pwm with diffrent dutycycle with MSP430G2231.

  • Yasin J.I. said:
    Is it possible to generate two pwm with diffrent dutycycle with MSP430G2231.

    Not in hardware. Only with a bit of software support and only for relatively low PWM frewuencies and only if the DC is somewhere in the middle (so e.g. 33-66% are simpler than 10-90%, the higher the required frequency, the narrower the area you can handle).

    Basic approach: Set up the timer for a convenient frequency. Set up the two CCR units for toggle mode and let them trigger an interrupt each. Inside the ISR, you add one of two valeus to the CCRx register. One that represents the 'oN' time in tiemr ticks, and one that represents the 'off' time.

    If e.g. the timer runs on 1MHz. The PWM frequency you want is 1kHz. So 1000 timer ticks are for one cycle. Then you write for e.g. a DC of 30% a value of 300 to CCRx, when the timer reaches the value of 300 and triggers the itnerrupt, you add 700, then 300, then 700. On each compare event, the output will toggle, goiving you as a result a PWM signal with 30% DC. This can be done for both CCR units independently.

    However, the value you add mus talways be large enough so the CPU can handle the current interrupt and maybe the other channels interupt before the count is reached. So you may never block interrupts, do much in any 3rd ISR or choose a DC that causes the value you have to add to be too small (so the next interrupt comes too fast), or you'll see the PWM signal 'elongated' for some time or even stall for a complete timer cycle.

  • Dear Jen,

    Thanks for the reply I will try to generate PWM as you said.

     

  • Yasin -

    I am trying to do something similar with the G2231. Two different duty cycles to generate different PWM waveforms to drive a two color LED light fixture. I was wondering if you got it to work for your servos. If you could share any of your lessons learned in the interrupt code, it would help me out a ton.

    Thanks

     

**Attention** This is a public forum