120deg phase offset pwm in one cog
Hi There,
I am trying to generate two 50% duty square waves with 120deg phase shift in one cog using the counters, at the highest freq I can, but still having some resolution to be able to change the phase.
The closest I can see as an example is the counterpwm.spin file posted elsewhere on the forum, but I don't see anywhere in the code how to adjust phase.
Can anyone give me a clue how to do this ..
Cheers,
bernie
I am trying to generate two 50% duty square waves with 120deg phase shift in one cog using the counters, at the highest freq I can, but still having some resolution to be able to change the phase.
The closest I can see as an example is the counterpwm.spin file posted elsewhere on the forum, but I don't see anywhere in the code how to adjust phase.
Can anyone give me a clue how to do this ..
Cheers,
bernie

Comments
' d120: clock ticks covering 1/3 of the total cycle ' d240: clock ticks covering 2/3 of the total cycle ' value: clock ticks covering 1/2 of the total cycle ' ' f = clkfreq/(d120+d240) ' CON cycle = 30 DAT org 0 ' counter/parameter setup omitted loop waitcnt target, d120 neg phsa, value waitcnt target, d240 neg phsb, value jmp #loop d120 long cycle/3 d240 long cycle/3*2 value long cycle/2 fitThe above .spin file requires passing start(pin,Freq,PwmAddr), can anyone remind me how to pass the PwmAddr pointer?
Cheers,
B