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.

Timer A for PWM

Other Parts Discussed in Thread: MSP430F4270, TPS62260LED-338

I am using MSP430F4270,

and i would like to have PWM signal on TA0 pin. it can produce PWM signal,

but the problem is if I change CCR0 or CCR1 value. the duty cycle or the period won't change.

can someone give me suggestion please..

below is the code

#include  <msp430x42x0.h>

void main(void)
{
  WDTCTL = WDTPW +WDTHOLD;                  // Stop WDT
   P1DIR |= 0x01;                            // P1.0 output
  P1SEL |= 0x01;                            // P1.0  TA0 option
  CCR0 = 512-1;                             // PWM Period
  CCTL0 = OUTMOD_7;                         // CCR1 reset/set
  CCR1 = 384;                               // CCR1 PWM duty cycle
   TACTL = TASSEL_1 + MC_1;                  // ACLK, up mode

  }

  • Try ta_16 in the following zip file, it illustrates how to set up a PWM with the timer and how to adjust the period & duty cycle: http://www.ti.com/lit/zip/slac077

  • yes, i've seen it, actually I made similar program based on that but instead of having output PWM on pin TA1 and TA2

    i'like to have the output on TA0

  • nandax said:

    yes, i've seen it, actually I made similar program based on that but instead of having output PWM on pin TA1 and TA2

    i'like to have the output on TA0

    Ok, I see. Please note the following from page 461 of the User's Guide: "The output modes are defined by the OUTMODx bits and are described in Table 15--2. TheOUTx signal is changed with the rising edge of the timer clock for all modes except mode 0. Output modes 2, 3, 6, and 7 are not useful for output unit 0, because EQUx = EQU0."

    Considering the above be careful you do not choose one of those modes for TA0 output.

  • thanks for the reply,

    so that means if I'd like to use TA0 as output for PWm signal. I can only use mode 0?

    so how can I change the duty cy cle if Idlike to have PWM signal in TA0

     

  • You're correct. For the true PWM modes of the timer, the period is set by TA0 (CCR0; the timer is in UP mode and counts up to CCR0) and the duty cycle is set by the respective TAx CCRx register (TA1, TA2, etc) for each of those outputs. The TAx outputs in this case become PWM outputs with fully automatic PWM signal generation.

    The TA0 output can in some cases be manipulated to essentially create PWM signals but not without direct modification by the CPU. This can be done by placing the timer in continuous mode and permanently modifying the CCR0 value (in the Timer ISR for example) to create varying high & low phases; but be careful. This can have an effect on the other TAx blocks depending on their configured mode and can also create issues in sycn'd updates when the timer is clocked async from the CPU. Of key concern is making sure the CCRx register is not manually modified as the timer TAR is counting across the old or new value. This can cause missed transitions as well as be a headache to debug.

    As a rule, hardware generated PWM (no CPU) using the Timers of the MSP430 is only possible on the TA1/TB1 and higher timer outputs. The TA0/TB0 is always the period control for all the other TA1+/TB1+ CCRx blocks.

    My recommendation is to use TA1 and higher for PWM generation. If you must use TA0, just take care that this is a largely manual process.

    As a reference, I believe an example of manual TA PWM generation on TA0, TA1 & TA2 is done here: http://focus.ti.com/docs/toolsw/folders/print/tps62260led-338.html

    Best of luck, Zack

  • I need of some sample program for PWM generation in assembly langauge

  • Hi

       Use the C codes from Slac077 and simulate it in Compiler which ever u r using and while running step by step the Assembly language is shown in debugging mode so u can copy that and try working with that Assembly commands.

  • Or go to the MSP430 Code Examples page and select the assembly version for IAR or CCE.

  • Hi Brandon,

    About those mps430 code examples....

    Could you please have someone fix RTC_Calendar.s43 within slaa290.zip? Its been broken since forever.

    The issue is the function 'setDate', which stomps all over R10 with the instruction 'mov.b   TI_mNumbers(r7), r10' without doing the usual push/pop sequence to preserve the current value.

    Thanks

    darkwzrd

  • Darkwzrd,

    Thanks for the heads up on the RTC Library. The code has been fixed and sent for publishing. It should be online in the next week or so.

    Regards, ~Miguel  

  • Hi Miguel,

    Thanks for the fix.

    You know, I re-read my original post and it sounded kind of snotty. I just wanted to point out that I didn't mean to be disrespectful in any way, shape or form. It's funny how sometimes when speaking and writing, using the same words, the meaning can be different in each context. I swear it sounded just fine in my head! =p

    Thanks again!

**Attention** This is a public forum