Author Topic: MSP430G2333 PWM generation capability  (Read 868 times)

0 Members and 1 Guest are viewing this topic.

Offline VK3DRBTopic starter

  • Super Contributor
  • ***
  • Posts: 2252
  • Country: au
MSP430G2333 PWM generation capability
« on: October 08, 2021, 01:49:23 am »
Hi.

I am fairly new to MSP430's but have I have programmed a state machine and a whole lot of functions into this chip so far without any problems so far.

I am using Timer0 to generate a 1ms timer tick through an interrupt, which is used for a whole lot of timing events in the main() - no issues and it works nicely.

The only thing in this project now is to generate two PWM's - one to port P2.0 and the other to port P2.1. They can both have a have a period of 1ms. The CPU clock is 1MHz.

I just need to vary the duty cycles on each of these outputs independently. Reading the datasheet, I think this is possible.

How can I generate the two PWM outputs without messing up Timer0? Can I use the second timer to generate the two independent PWM duty cycles? If so, how should the registers be set up? Any suggestions much appreciated!
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1421
  • Country: us
  • Very dangerous - may attack at any time
Re: MSP430G2333 PWM generation capability
« Reply #1 on: October 08, 2021, 07:04:16 am »
You can use Timer1 for the PWM. Just set CCR0 to the PWM period, CCR1 to the duty cycle of the first PWM, and CCR2 to the duty cycle of the second PWM. Set timer mode to up, and the output modes to set or reset.

The first PWM can be output on P2.1, P2.2 or P3.2. The second PWM can be output on P2.4, P2.5 or P3.3.

If you must have PWM on P2.0 then this method can be used to get PWM from CCR0 in addition to CCR1 and CCR2. The pins for CCR0 are P2.0 and P2.3.
https://forum.43oh.com/topic/5619-pwm-using-timer-output-toggle-mode/
 

Offline VK3DRBTopic starter

  • Super Contributor
  • ***
  • Posts: 2252
  • Country: au
Re: MSP430G2333 PWM generation capability
« Reply #2 on: October 11, 2021, 03:05:47 am »
Thanks, oPossum.

You post provided hints which helped me sold the problem, although I did not use your three PWM solution. Because my PCBA was only in the proto stage, I could swap P2.0 with P2.4 (with some microsurgery on 0.2mm tracks). And voila! It all works beautifully. I used Timer0 for a 1ms timer tick, and TA1CCR1 and TA1CCR2 for the independent PWMs. A re-spin was required anyway, so it is easy to swap the tracks.

After I got this going the rest of the coding to vary the duty cycles dynamically was a piece of cake. The firmware part of the project is complete.

If you ever travel to Melbourne, Australia, I will shout you a beer :-+.

Incidentally, the MPS430G2333's are very nice, but for pin-steering there are newer devices that are far more flexible. Code Composer is OK, but in my opinion IDEs with register wizards like CodeVision/AVR (for AVR's) kills it as far as speed of development goes. But it's free and it works, so I cannot complain.

Most importantly, I can source the 28-pin MSP420G2333 during the global shortages, where as STM is a basket case. This product has the potential of being very high volume, and when STM finally decides to free up supply, I am not interested. If chip vendors cannot supply to the engineering fraternity now, they will lose out in the long run.

Once again, THANKS!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf