PDA

View Full Version : ASM question



Charles Linquis
- 19th March 2010, 19:37
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 ?

rmteo
- 19th March 2010, 19:56
Since all SFR's are located in the Access Bank, use this:


btg PORTG,4,0

Darrel Taylor
- 20th March 2010, 19:40
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>

rmteo
- 20th March 2010, 20:53
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. :rolleyes:

Bruce
- 20th March 2010, 22:51
Since all SFR's are located in the Access Bank
Not on ALL 18F parts they're not, so be careful.

rmteo
- 20th March 2010, 23:32
Not on ALL 18F parts they're not, so be careful.
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. :D:D:D

Charles Linquis
- 21st March 2010, 00:34
Thank you all.

And about that linear addressing space and 4MB of FLASH:

While my coding abilities have not really progressed past the 18Fs, my hardware needs have.

I have an ARM9 development kit and I'm re-learning 'C' ...

rmteo
- 21st March 2010, 01:04
Just out of curiosity, which ARM9 are you using?

Darrel Taylor
- 22nd March 2010, 19:04
Just thinking about the old R-M-W problem.
It would probably be better to ...
@ btg LATG,4

Charles Linquis
- 23rd March 2010, 00:25
In fact, that is what I wound up doing.

And Darrel, while I have your ear...

DT_Ints seems to screw up the ICD2 debugger. I get a "duplicate labels" error just past point where the int handler is inserted.

I seem to remember something about this in the MPASM manual, but can't find it right now. Is there some secret I need?

And, I'm assuming I can remove the 'Disable Debug' and 'Enable Debug' labels in DT_INTs18, correct?

Darrel Taylor
- 23rd March 2010, 00:33
Try this version of DT_INTS-18 ...

http://www.picbasic.co.uk/forum/showthread.php?p=82826#post82826
<br>