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.

PWM Output on TA0 using TACCR0 with the MSP430F4250

Other Parts Discussed in Thread: MSP430F4250

So we are using all the ADC channels for ADC's on our MSP430F4250. We want to use TA0 pin for a PWM output to control an LED. In order to start the PWM running, all I have to do is select the clock, set the pin to use TA0, and set the TACCR0 register, correct? Once TACCR0 is set, shouldn't TAR start counting up? We are also setting it to up mode.

Initially I was using both TACCR0 and TACCR1 where TACCR1 was setting a duty cycle. But if I only need a square wave (which is the case), can't I just use the TACCR0 register and set the TA0 bit to output the pwm? I ask because my PWM is no longer working now that we allocated all the ADC pins for ADC's.

Thanks!

  • Hey Rob,

    Are you using the PWM to pulse or dim the LED? If not why not just use the TA0 pin to turn the LED on or off.

    The problem is without the capture and compare register (CCR1) you wont be able to change the duty cycle of the PWM. In fact i think you will only get either just a high or a low out of the pin. The CCR0 sets the TAC count and is usually used to set the frequency of your PWM (by clock freq/No in CCR0, eg 4Mhz/200 = 20kHz), then the CCR1 will set your duty cycle (D).

    If you can't change to a chip with more pins and peripherals you might have to lose the PWM functionality to drive the LED unfortunately.

    Hope this helps

    Michael D

  • Robert Scaccia said:
    Once TACCR0 is set, shouldn't TAR start counting up? We are also setting it to up mode.

    No. TAR cont sindependently of CCR0. CCR0 is just triggering a 'TAR reset) when TAR reaches CCR= and the tierm is in up mode :)
    However, if CCR0 is 0 and the tiemr is in up mode, it will count from 0 to 0 and then begin with 0 again, so it seems stopped. it isn't. :)

    Robert Scaccia said:
    But if I only need a square wave (which is the case), can't I just use the TACCR0 register and set the TA0 bit to output the pwm?

    Yes you can. Configure the timer in up mdoe, but configure CCR0 for half the value (twice the frequency). Then set a toggle outmode.

    The tiemr will run from 0 to CCR=, toggle the output pin, then restart from 0. Effectifely you'll get a square wave 50% DC with 1/2 the PWM frequency set with CCR0.
    However, a DC of fixed 50% cannot be called a PWM anymore. It's just a fixed-frequency clock signal.

    Th eonly way to use TA.0 as PWM output is when you use the timer in cont mode. THen the PWM frequency is controlled by the tiemr frequency (one cycle = 65536 ticks) and CCR0 (as well as all other CCRs) can be used as PWM outputs with a resolution of 1/65536.

  • Jens-Michael Gross said:
    Th eonly way to use TA.0 as PWM output is when you use the timer in cont mode. THen the PWM frequency is controlled by the tiemr frequency (one cycle = 65536 ticks) and CCR0 (as well as all other CCRs) can be used as PWM outputs with a resolution of 1/65536.

    To add to what Jens-Michael said, you can find an example of how he's talking about doing a PWM with any duty cycle (not just 50%) by using continuous mode in this app note: http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa513 Could be useful if you decide you want LED dimming functionality by varying your duty cycle.

    Regards,

    Katie

**Attention** This is a public forum