Access Bank Clarification

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Access Bank Clarification

Postby lionkingleo » Wed Jul 25, 2018 3:00 pm

Having spent some considerable time trying to understand the Bank selecting strategy employed in a PIC18F 4520 CPU, I still find it very confusing and would appreciate a clear explanation. From the data sheets, the access bank comprises 256 bytes of data Ram encompassing an address range of 00 - FF. Within that range, Addresses 00 - 7F comprise general purpose registers (GPR's) while addresses 80 - FF encompass the special function registers To modify data in the access bank requires you only to set the suffix 'a' in the instruction to 0. My confusion is over the fact that the SFR registers such as PORTA - PORTE are also listed as being in Bank 15. To access the PORTA register for example, do I have to explicitly set the BSR to 15 and set the suffix 'a' in the instruction to 1? or can I simply access PORT A using the suffix 'a' in the instruction set to 0? The movwf instruction states that if 'a' = 1, the bank select register is used to select the GPR bank (default) so presumably the BSR must be set to 15 prior to using the movwf instruction as follows:
movlb .15 ; select bank 15
movlw 0x0F
movwf PORTA,1 ; update PORT data

or is this better?

movlb .0 ; clear BSR
movlw 0x0F
movwf PORTA,0 ; force use of access bank

Any feedback would be appreciated ...suffered a minor stroke back in January, so I find that I need clarity of understanding before digging a deep hole for myself.

Thank you!!
lionkingleo
 
Posts: 2
Joined: Thu Jul 05, 2018 10:36 am
PIC experience: Experienced Hobbyist

Re: Access Bank Clarification

Postby vloki » Wed Jul 25, 2018 3:28 pm

Whith the RAM access bit in the instruction you select whether the BSR is used for addressing or not.

-> if you use access mode (without BSR) it makes no sense to configure BSR at all.

If the BSR is not used only the access bank is available, which is composed from lower part of bank 0 and higher part of bank 15 which holds all SFRs.
See figure 5-6 Data Memory Map...
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Access Bank Clarification

Postby ric » Thu Jul 26, 2018 2:18 am

lionkingleo wrote: Within that range, Addresses 00 - 7F comprise general purpose registers (GPR's) while addresses 80 - FF encompass the special function registers

The actual division depends upon which specific PIC18F device you are using. Not all of them switch from one to the other at 0x80.
e.g. in a PIC18F24K42, the division is at 0x60.
So, 0x00 to 0x5F accesses GPRs (the first 96 bytes of bank 0) and 0x60 to 0xFF accesses SFRs (the last 160 addresses in bank 15)

The whole point of the Access Bank is it lets you access those register WITHOUT touching the bank select register.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Access Bank Clarification

Postby lionkingleo » Thu Jul 26, 2018 4:27 pm

Thanks to all who submitted replies .... Nice to get some independent confirmation

Thank you !!
lionkingleo
 
Posts: 2
Joined: Thu Jul 05, 2018 10:36 am
PIC experience: Experienced Hobbyist


Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 6 guests