Hi,
I'm trying to build a Pulse Width Modulator using a PIC16F84a.
If possible, I want one of my inputs to increase the duty factor of the LED every time it is asserted and the other input to decrease the duty factor.
I think I've got a decent schematic drawn up and a rough start on the code, but I'm having trouble coming up with an effecient way to program the inputs so that they continually increase or decrease the duty factor each time one is asserted.
Any help would be appreciated! Thanks
I'm trying to build a Pulse Width Modulator using a PIC16F84a.
If possible, I want one of my inputs to increase the duty factor of the LED every time it is asserted and the other input to decrease the duty factor.
I think I've got a decent schematic drawn up and a rough start on the code, but I'm having trouble coming up with an effecient way to program the inputs so that they continually increase or decrease the duty factor each time one is asserted.
Any help would be appreciated! Thanks
Rich (BB code):
; cpu equates (memory map)
portB equ 0x06
portA equ 0x05
duty equ 0x0c
org 0x000
start movlw 0x00
tris portB
clrf portB
movlw 0x1F
tris portA
clrf portA
test0 btfsc portA, '0'
call test1
call upLED
test1 btfsc portA, '1'
goto test0
call downLED
upLED movlw d'64'
movwf duty
bsf portB, '0'
light decfsz duty
goto light
clrf portB
movlw d'255
movwf duty
blank decfsz duty
goto blank
goto upLED
Attachments
-
109.1 KB Views: 30