Hi,
I have recentely accuired a PicKit2 Programmer Starter kit and am working my way thru the Demo lessome that came with it. I have done all the lessons and am now going back thru them and making changes to se if i get the result I expect.
I have exended the code in lesson one as follows;
cblock 0x20
Delay1 ; Assign an address to label Delay1
Delay2
Display ; define a variable to hold the display
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin RC0 an output
bcf TRISC,1 ; make IO Pin RC1 an output
bcf TRISC,2 ; make IO Pin RC2 an output
bcf TRISC,3 ; make IO Pin RC3 an output
bcf STATUS,RP0 ; back to Register Page 0
clrf PORTC
bsf PORTC,0 ;turn on led DS1
Call OndelayLoop
bsf PORTC,1 ;turn on led DS2
Call OndelayLoop
bsf PORTC,2 ;turn on led DS2
Call OndelayLoop
bsf PORTC,3 ;turn on led DS3
Goto Finish
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
Return
Finish:
goto $ ; wait here
end
DS1 to DS4 are leds on the demo board included in the kit.
The problem I am having is when the 'bsf PORTC,1' executes the LED that was on previously turns off (which I do not want)indicating that bsf PORTC bit 0 has been cleared. The dcs give me the impression that this instruction should only affest bit 1. I want the four LEDs to turn each in series and stay on so I end up with alll four on. I can do this by using a the display variable to hold a byte indicating conbinations of leds (eg 0x3 for dS1 & dS2) and mowing that to the prot via w. I want to see if I can do it with bsf commands.
Am i missing something and if so can someone fill me in on what?
Regards
Dom
I have recentely accuired a PicKit2 Programmer Starter kit and am working my way thru the Demo lessome that came with it. I have done all the lessons and am now going back thru them and making changes to se if i get the result I expect.
I have exended the code in lesson one as follows;
cblock 0x20
Delay1 ; Assign an address to label Delay1
Delay2
Display ; define a variable to hold the display
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin RC0 an output
bcf TRISC,1 ; make IO Pin RC1 an output
bcf TRISC,2 ; make IO Pin RC2 an output
bcf TRISC,3 ; make IO Pin RC3 an output
bcf STATUS,RP0 ; back to Register Page 0
clrf PORTC
bsf PORTC,0 ;turn on led DS1
Call OndelayLoop
bsf PORTC,1 ;turn on led DS2
Call OndelayLoop
bsf PORTC,2 ;turn on led DS2
Call OndelayLoop
bsf PORTC,3 ;turn on led DS3
Goto Finish
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
Return
Finish:
goto $ ; wait here
end
DS1 to DS4 are leds on the demo board included in the kit.
The problem I am having is when the 'bsf PORTC,1' executes the LED that was on previously turns off (which I do not want)indicating that bsf PORTC bit 0 has been cleared. The dcs give me the impression that this instruction should only affest bit 1. I want the four LEDs to turn each in series and stay on so I end up with alll four on. I can do this by using a the display variable to hold a byte indicating conbinations of leds (eg 0x3 for dS1 & dS2) and mowing that to the prot via w. I want to see if I can do it with bsf commands.
Am i missing something and if so can someone fill me in on what?
Regards
Dom