;****Set up the port****
This is part of the code from a tutorial found
**broken link removed**
this is what iv gathered from this tutorial. To set up a port you have to switch to bank1 the enter the binary or hex numer for which bits you want on. In this case they want bit 2 of port a on. so the decimal val would be 00010 or 02h and that has to be place in the general register first and the that value is moved to the TRISA register. now TRISA holds the value of which ports are input and which are output.
Why does this code seam to set it to 00h first then go back and change it to 02h? Why not just set it to 02h in the first place?
Code:
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output.
bcf STATUS,5 ;Switch back to Bank 0
movlw 02h ;Set up our w register with 02h
This is part of the code from a tutorial found
**broken link removed**
this is what iv gathered from this tutorial. To set up a port you have to switch to bank1 the enter the binary or hex numer for which bits you want on. In this case they want bit 2 of port a on. so the decimal val would be 00010 or 02h and that has to be place in the general register first and the that value is moved to the TRISA register. now TRISA holds the value of which ports are input and which are output.
Why does this code seam to set it to 00h first then go back and change it to 02h? Why not just set it to 02h in the first place?