Darkstar64
New Member
Hey well im code is almost complete but I am missing one more thing and thats the delay times im a little confused on them so here is what im trying to achieve I multiplexed 12 leds with 4 outputs and 2 inputs to control what operation is exec anyways since only one LED can be on at a time I need them to cycle fast so that it looks like there all on at the same time but really there not they need to be cycling for 3-4 seconds so lets use a letter as a example say J the letter J needs to be on for 3-4 seconds but as stated before only one LED can be on at one time so im unsure how to do this. This is what I have so far I also included the Delay subroutine of 10ms and one of the LED subroutines as well and last but not least the code I have so far this only loops 13 times im not sure how long that is but it needs to loop for 3-4 seconds so the J stays on for 3-4 seconds I also want to add in curcuit programming what do I need electronic wise to seperate the pins from the main electronics so that the PIC can be programmed I was told you couldn't just add the wires you had too seperate the PIC from the main electonics first before you did any programming otherwise it would fry the PIC
Code:
;****************** Delay Subroutine ( 10 ms )
delay10 ; Delay W x 10ms
movwf dc3 ; Delay = 1 + W x (3 + 10009 + 3) - 1 + 4 -> W x 10.015ms
dly2 movlw .13 ; Repeat inner loop 13 times
movwf dc2 ; -> 13 x (767 + 3) - 1 = 10009 cycles
clrf dc1 ; Inner loop = 256 x 3 - 1 = 767 cycles
dly1 decfsz dc1,f
goto dly1
decfsz dc2,f ; End middle loop
goto dly1
decfsz dc3,f ; End outer loop
goto dly2
retlw 0
Code:
;****************** LED Subroutine
lightledA
movlw b'111010' ; Configure GP4 and GP1 as input
tris GPIO
movlw b'000001' ; Change corresponding bit of GP0 to 1
movwf GPIO ; Writes 1 to GP0
movlw delaytime ; Get from dealytime variable
call delay10 ; Delay of 50 x 10ms = 500ms or .5s
movlw shadow ; Change corresponding bit of GP0 to 0
movwf GPIO
movlw b'101000' ; Configure GP0,GP1,GP2,GP4 to outputs
tris GPIO ; Write 0 to GP0
retlw 0
Code:
movlw .13 ; Loops 13 times
movwf cv1 ; Writes 13 to cv1
cv5 call lightledC ; Letter J
call lightledB
call lightledA
call lightledD
call lightledG
call lightledG
call lightledH
call lightledI
call lightledJ
call lightledK
call lightledL
decfsz cv1,f ; Decrement counter is set to 13
goto cv5 ; If Decrement counter is not 0 then repeats loop
Last edited: