Led candle code doesn't work with 16f84a
Thanks again 3v0 for the link but unfortunately the code comes back from my winpic programmer with errors.
I presume that would be because i'm using a 16f84a instead of the original 12f675.
Can anyone help me with the alterations needed to get this to work on my pic.
Here is the hex..
:020000000528D1
:1000080009008316003085007F3090008312271482
:100018007F30A400A5002408A6001E203B20073935
:10002800031D1A282E20A400003CA5002508A600C0
:100038001E200F286430A2002608A000003CA10062
:1000480085160000A00B252885120000A10B292881
:10005800A20B20283B203F39A3003B203F39A307B0
:100068003B203F39A3073B203F39230708002708D7
:100078002807A8002907A9002A07AA002B07AB0010
:0E0088000310AB0D03182B142B08A70708005C
:02400E00840F1D
:02FFFE00750686
:00000001FF
And here is the source code..
; Candle Simulation
; 6/04 Luhan Monat
;
; Simulate flicker of candle using incandescent lamp
;
device PIC12F675,intrc_osc,pwrte_on,wdt_off
org 20h
del1 ds 1
del2 ds 1
pcnt ds 1
temp ds 1
lev1 ds 1
lev2 ds 1
level ds 1
rbuf ds 5
LAMP = gp.5
org 0
goto start
org 4
reti
start bsf RP0
movlw 0
movwf GP
movlw 127
movwf OSCCAL
bcf RP0
bsf rbuf,0 ;seed random number
movlw 127
movwf lev1 ;initial light level
movwf lev2
; Main Loop
; Create hi and low power levels
; Switch between levels
candle movf lev1,w
movwf level
call power ;do lev1 power
call rando
andlw 7
btfss z
goto :run ;skip 7 out of 8
call rmid ;generate new hi and low levels
movwf lev1
sublw 0
movwf lev2
:run movf lev2,w ;do lev2 power
movwf level
call power
goto candle
; PWM power control
power movlw 100 ;set flicker rate: higher=slower
movwf pcnt ;set loop count
1 movf level,w ;get target level
movwf del1 ;set 1st delay
sublw 0
movwf del2 ;set 2nd delay
bsf LAMP ;power on
3 nop
decfsz del1 ;do 1st delay
goto
3
bcf LAMP ;power off
4 nop
decfsz del2 ;second delay
goto
4
decfsz pcnt
goto
1
; find sum of 4 random numbers
; skews results around 127
rmid call rando
andlw 3fh
movwf temp
call rando
andlw 3fh
addwf temp
call rando
andlw 3fh
addwf temp
call rando
andlw 3fh
addwf temp,w
ret
; Pseudo Rando Number
; "Chop Suey Machine"
rando movf rbuf,w
addwf rbuf+1,w
movwf rbuf+1
addwf rbuf+2,w
movwf rbuf+2
addwf rbuf+3,w
movwf rbuf+3
addwf rbuf+4,w
movwf rbuf+4
bcf c
rlf rbuf+4
btfsc c
bsf rbuf+4,0
movf rbuf+4,w
addwf rbuf
ret
end
QED
Thanks in advance....
Greg.