I am trying to program pwmout on an 18M2+ using ......
PWMOUT PWMDIV64, pin, period, duty_cycles
Period has to be integer 0 to 255 and duty_cycles has to be an integer 0 to 1024
and it turns out that if the duty_cycles integer value is always kept twice the period integer value it will always generate a 50% duty square wave train of pulses at a frequency depending on the period integer value.
So.... pwmout pwmdiv64, B.3, 254, 508 ..... is the lowest frequency obtainable
and ..... pwmout pwmdiv64, B.3, 127, 254 ...... will be a higher frequency approx. double that frequency.
PWMDIV64, PWMDIV16 etc gives coarse freq. control by dividing by 16 or 64 etc.
There is not a command to enter a period value on its own but there is a command to enter PWMDUTY on its own.
And the manual recommends using PWMDUTY to change duty rather than another PWMOUT command as PWMOUT stops and starts the timer each time whereas PWMDUTY just varies the duty value on a continuous train.
So in my case if I want a continuous train I would need a command to enter a period value along with 2 times that value for duty_cycles.
When I issue new PWMOUTs .... I can get glitches etc at where the transitions takes place, not bad, but sometimes noticeable....
Is there a way of talking directly to the actual registers for period that would do this either by basic code or assembler etc so that when pwmout is started it would just continually read the period and duty values and follow them if they changed without issueing another pwmout command. ......????
PWMOUT PWMDIV64, pin, period, duty_cycles
Period has to be integer 0 to 255 and duty_cycles has to be an integer 0 to 1024
and it turns out that if the duty_cycles integer value is always kept twice the period integer value it will always generate a 50% duty square wave train of pulses at a frequency depending on the period integer value.
So.... pwmout pwmdiv64, B.3, 254, 508 ..... is the lowest frequency obtainable
and ..... pwmout pwmdiv64, B.3, 127, 254 ...... will be a higher frequency approx. double that frequency.
PWMDIV64, PWMDIV16 etc gives coarse freq. control by dividing by 16 or 64 etc.
There is not a command to enter a period value on its own but there is a command to enter PWMDUTY on its own.
And the manual recommends using PWMDUTY to change duty rather than another PWMOUT command as PWMOUT stops and starts the timer each time whereas PWMDUTY just varies the duty value on a continuous train.
So in my case if I want a continuous train I would need a command to enter a period value along with 2 times that value for duty_cycles.
When I issue new PWMOUTs .... I can get glitches etc at where the transitions takes place, not bad, but sometimes noticeable....
Is there a way of talking directly to the actual registers for period that would do this either by basic code or assembler etc so that when pwmout is started it would just continually read the period and duty values and follow them if they changed without issueing another pwmout command. ......????