In an 18F, can I access the ports without worrying about the bank?
For example:
if I use
@ btg portg,4
Will that always work to replace the PBP instruction
Toggle PortG.4 ?
In an 18F, can I access the ports without worrying about the bank?
For example:
if I use
@ btg portg,4
Will that always work to replace the PBP instruction
Toggle PortG.4 ?
Charles Linquist
Since all SFR's are located in the Access Bank, use this:
Code:btg PORTG,4,0
Whenever you are using something located in the ACCESS bank ...
The assembler automatically recognizes it and adds the 0 for you.
@ btg portg,4
is all you need.
<br>
DT
Yes, the "0" is optional. I prefer to always include it to prevent issues when not working with the Access Bank - as a reminder to use a "1" and to ensure the correct GPR bank is selected in the BSR.
Working with different MCU's from PIC's to high end ARM's, doing little things like this can prevent major debugging headaches down the road.![]()
Not on ALL 18F parts they're not, so be careful.Since all SFR's are located in the Access Bank
Yes, many of the newer 3.3V J series (particularly those with USB and/or Ethernet) do have SFR's located in other than the Access Bank. IIRC, Charles uses a PIC18F8722 (or 8723) and in that case, all the SFR's are located in the Access Bank.
In any event, you have highlighted one of the main reasons PIC's (particularly the PIC16/18) are not my current choice of MCU - too many gotchas, Ram Banks, Code Pages, etc., although the PIC24/dsPIC are somewhat better in this respect. There is something to be said in having 4GB of linear addressing space for both code and data.![]()
Bookmarks