Hi Guys,
I’m using Pic 16F877A, and have had a hardware PWM 10kHz signal working fine for a while.
I use this code generated by an online calculator, and connect to portC.2 which is supposed to be channel 1.
That was all fine...
Now a little later i have a timer1 overflow interrupt running at 100 Hz interval,
and decided to throw in a kind of timer driven software PWM of 50Hz using this code:
Now I find the 50Hz signal is perfect on portC.1, but portC.2 that is supposed to have a 100Hz
signal is also putting out the same 50Hz signal!
It makes no difference if I move the 50Hz PWM to portC.0.
I realise bit access is not recommended (RWM) on a hardware PWM port, but really?
Why the same spot on 50Hz signal? I wanted both.
Is it possible to output timer interrupt on one of the portC pins without messing up the HPWM?
It doesn’t need to be 50Hz, just a signal I can mark, and compare to another signal with a 2 channel scope.
Cheers, Art.
I’m using Pic 16F877A, and have had a hardware PWM 10kHz signal working fine for a while.
I use this code generated by an online calculator, and connect to portC.2 which is supposed to be channel 1.
Code:
PR2 = 0b11111001 ;
T2CON = 0b00000100 ;
CCPR1L = 0b01111100 ;
CCP1CON = 0b00111100 ;
Now a little later i have a timer1 overflow interrupt running at 100 Hz interval,
and decided to throw in a kind of timer driven software PWM of 50Hz using this code:
Code:
‘in 100 Hz timer overflow ISR straight after timer reload
‘
btfsc flipflop ,00 ; 1/2
goto aaaa ; 2
goto bbbb ; 2
aaaa: ‘
bsf portc, 01 ; 1
goto overpwm ; 2
bbbb: ‘
nop ; 1
bcf portc, 01 ; 1
overpwm ‘
comf flipflop ,F ; 1 - but timing doesn’t matter here
‘instruction time 6 for flip state, 6 for flop state,
‘7 for the code to execute no matter the status
signal is also putting out the same 50Hz signal!
It makes no difference if I move the 50Hz PWM to portC.0.
I realise bit access is not recommended (RWM) on a hardware PWM port, but really?
Why the same spot on 50Hz signal? I wanted both.
Is it possible to output timer interrupt on one of the portC pins without messing up the HPWM?
It doesn’t need to be 50Hz, just a signal I can mark, and compare to another signal with a 2 channel scope.
Cheers, Art.