Picomite Phase Correct PWM


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3348
Posted: 06:10am 09 Jan 2023      

Combining the latest firmware with Volhout's expertise:-

Symetrical + inverted PWM on any channel

f2 = 2 * PWMfrequency
PWA% = &H40050000 + &H14 * PWM_ChannelNumber   'Hex. address plus offset or -
PWA% = 1074069504 + 20 * PWM_ChannelNumber     'Decimal address plus offset
DY = Duty '(Percent)
Poke word PWA%,3
PWM PWM_ChannelNumber, f2, DY, (DY - 100)

'eg
> setpin GP4,pwm  'PWM ch 2 a
> setpin GP5,pwm  'PWM ch 2 b
> PWA% = &H40050000 + &H14 * 2
> f2 = 2 * 1000 'Hz
> DY = 44 'pw%
> Poke word PWA%,3
> pwm 2, f2, DY, (DY - 100)
>
_