Winch
Member
Dear all,
I want to bring out a PWM signal to gate 6 of a PIC 16F628A.
I have the following code written.
Can someone help me?
P.S. this code is first written in Proton, I'm trying to convert it to oshonsoft.
In proton you can use the PWM instruction for every port, I hope this is also the case with oshonsoft?
I want to bring out a PWM signal to gate 6 of a PIC 16F628A.
I have the following code written.
Can someone help me?
P.S. this code is first written in Proton, I'm trying to convert it to oshonsoft.
In proton you can use the PWM instruction for every port, I hope this is also the case with oshonsoft?
HTML:
'DEVICE 16F628A
Define CONFIG = 0x3f50
AllDigital 'alle ports digital
'port names
Symbol pwm_signaal = PORTA.6 'this port is the PWM signal
Symbol higherkey = PORTB.0 'key to increase
Symbol lowerkey = PORTB.1 'key to decrease
'declaring variable
Dim duty As Byte 'This variable contains the duty (PWM duty value)
'76543210
PORTA = %00000000 'make all the gates of PORTA low
TRISA = %10111111 'PORTA.6 is output for PWM signal
ConfigPin PORTB = Input 'pull-up to activate the buttons
PWMon 1, 10
'mainprogram
main: 'loop
If higherkey = 0 And duty < 250 Then duty = duty + 1 'as on 'Higher Key "is pressed and value is still more, then increase it
If lowerkey = 0 And duty > 0 Then duty = duty - 1 'as on 'Lower Key' is pressed and value is still not zero, then decrease it
PWMduty 1, duty
Goto main
End