First, let us set up Port A bit 2 as an output:
bsf 03h,5 ;Go to Bank 1
movlw 00h ;Put 00000 into W
movwf 85h ;Move 00000 onto TRISA – all pins set to output
bcf 03h,5 ;Come back to Bank 0
bsf 03h,5 ;Go to Bank 1
movlw 00h ;Put 00000 into W
movwf 85h ;Move 00000 onto TRISA – all pins set to output
bcf 03h,5 ;Come back to Bank 0
This should be familiar from the last tutorial. The only difference is that I have set all of the pins on Port A as output, by sending 0h to the tri-state register.
We define a label very simply. We type a name, say START, then type the code:
Start movlw 02h ;Write 02h to the W register. In binary this is
;00010, which puts a ‘1’ on pin 2 while keeping
;the other pins to ‘0’
movwf 05h ;Now move the contents of W (02h) onto the
;PortA, whose address is 05h
movlw 00h ;Write 00h to the W register. This puts a ‘0’ on
;all pins.
movwf 05h ;Now move the contents of W (0h) onto the Port
;A, whose address is 05h
goto Start ;Goto where we say Start
As you can see, we first said the word ‘Start’ right at the beginning of the program. Then, right at the very end of the program we simply said ‘goto Start’. The ‘goto’ instruction does exactly what it says.
i have so many doubts in pic can you help me
ReplyDeletei am a btech student i want to do a project with pic but i dont know how to do it let me help.....
my email id:shabeebparambil@gmail.com
shabeebmoosa@yahoo.com