i've changed 'DIR porta out' to 'TrisA = 0b001000' but the switch still has no effect;the chip is outputting the correct PWM but it won't change on the button press...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are using fixed mode PWM. The frequency and duty are fixed at the frequency and duty as specified by the PWM constants. As you cannot change the constants in your running program what you are getting is the correct behaviour for fixed mode.
You need to use Variable mode PWM.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i thought obout that just before you posted! its 'set and forget' PWM...now to try the same idea using variable PWM.if i can get my head round the examples...still at least it does output 2 PWM waveforms albeit on seperate pins! why only2? simple..the lowpincount board only has 2 'linked' LEDs.
Last edit: HackInBlack 2019-08-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
adapted from an example file;the pushbutton 'should' change the duty-cycle on channel 1,but won't do anything...can anyone see whats wrong?
chip 12F1572, 32
The Switch_Port In is overwritten by PortA Out. Could set each individual pin, or use TrisA = 0b001000
i've changed 'DIR porta out' to 'TrisA = 0b001000' but the switch still has no effect;the chip is outputting the correct PWM but it won't change on the button press...
You are using fixed mode PWM. The frequency and duty are fixed at the frequency and duty as specified by the PWM constants. As you cannot change the constants in your running program what you are getting is the correct behaviour for fixed mode.
You need to use Variable mode PWM.
i thought obout that just before you posted! its 'set and forget' PWM...now to try the same idea using variable PWM.if i can get my head round the examples...still at least it does output 2 PWM waveforms albeit on seperate pins! why only2? simple..the lowpincount board only has 2 'linked' LEDs.
Last edit: HackInBlack 2019-08-06
See C:\GCB@Syn\GreatCowBasic\Demos\pwm_solutions\pic_pwm16_examples in your installation. There are a lot of demos specific to your chosen chip.
#chip 12F1572, 32
' not sure if the 80 is right but at least its visible! and it works as expected
Excellent news.
Enjoy