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.

MSP430F2122: PWM Output on P2.3 & P2.4 Setup for Inverse Operation

Part Number: MSP430F2122


I'm new to the MSP430 product lineup. I'm trying to setup PWM on P2.3 and P2.4 with in a way so when P2.3 is high P2.4 is low. Are there any resources recommended to read for setting this up? Eventually I would like to read a value of a potentiometer and adjust the duty cycle accordingly to the ADC input. 

  • Hi Joshua,

    On this device, no, not directly. 

    The TimerA module can generate a PWM on P2.3 and P2.4 using TACCR1 and TACCR2.  You will chose a value for TACCR0, which sets the period of your duty cycle, then select a value for both TACCR1 and TACCR22 to generate the duty cycle.  Example -  if TACCR0 = 32768 and TACCR1 = TACCR2 = 16384 then both outputs will be a 50% duty cycle, and in phase.

    Next, you need to choose the output mode, either mode 3 (SET/RESET) or MOD 7 (RESET/SET), let's say mode 3 for both in this example. You can read more about the output modes and the timer operation in the family users guide, section 12. This will generate the "in-phase" PWM on both output pins, but that's not what you want, so if you switch one of the outputs to mode 7 this will flip its output phase, but will no longer be aligned with the other output.  To fix this set TACCR1 to whatever duty cycle you want and set TACCR2 = (TACCR0 - TACCR1).

    Let me know if you have any issues with this.

  • This helps a lot. I'm looking at figure 12-9 for the output  unit in Up/Down mode. Which is how I'll have to implement the desired dead-time right?  Currently depending on what I set TACCR1 to and which output mode is selected the wave forms have zero dead-time at a leading edge or at a following edge but not centered.  

    I discovered setting the mode to up/down and using MOD_2 and MOD_6 yields the result I was looking for. It does seem to have a little more jitter as I have to lower the TACCR0 value a fair bit to attain the target frequency with this setup. Not sure if the jitter is caused by that or not.  

  • Hi Joshua,

    Ok, MOD_2 and MOD_6 in up/down mode is a good one as well.  What is your target frequency?

  • I'm aiming for around 28kHz.  I couldn't seem to get MOD_3 & 7 to allow any dead-time adjustment on both the rising and falling side. I could get it on one side or the other but not centered with equal dead-time until I changed to up/down and 2/6.  Perhaps I was missing something obvious with the first attempts.  I'm very new to the MSP430 world.  

**Attention** This is a public forum