Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 251352

Forum Post: RE: How to Get 180 degree phase shift between two pwm pulses in MSP430G2553

$
0
0

[quote user="srinivas nandam"]

thank you so much. but how to ensure the second pulse with 90degree delay

[/quote]

In your main () you choose 200 timer counts offset between TA0CCR1 and TA0CCR2 which is 90 degrees.

The case2: and case4: interrupts to start the pulse going high will occur 200 counts apart.

First interrupt in case2 @

TA0CCR1 = 5;

First interrupt in case4 @

TA0CCR2 = 205;

each gets incremented by a total of 800 counts in the interrupt routine.

I picked 5, 205 rather than 0, 200 because TA0R starts at 0 and will have to overflow before reaching 0 again.

So case2: occurs every 800 additional counts to set the pulse high TA0R = 5, 805, 1605, …64005, 64805, 70, 870, ...

And case4: occurs every 800 additional counts to set its pulse high TA0R = 205, 1005, 1805, …64205, 65005, 270, 1070, …

As long as the time taken to add 800 counts to TA0R in case2 is the same time taken in case4 and as long as interrupts don't delay each other, you should be able to maintain 90 degrees phase.

Otherwise you'll have to figure out some way to save the TA0R value gotten in case2 to use in case4 to add the 200 counts to constantly maintain 90 degrees separation.


Viewing all articles
Browse latest Browse all 251352

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>