| Title |
Title
Macros for Page and Bank Switching
|
|---|---|
| Name |
Name
AN586
|
| Date |
Date
06/24/2015
|
| Description |
Description
This application note discusses the use of the MPASM assembler's conditional assembly to automatically switch between program memory pages or to set the data memory banks. These macros, along with the long call technique (Application Note AN581), ease the development of software. Though the use of these macros can simplify program memory paging and data memory banking with minimal software overhead, the use of these macros without thought can cause unnecessary (duplicate) instructions to be used, by setting page or bank bits unnecessarily. The PIC16C5X family of devices has an architecture in which program memory has up to four pages of program memory (512 words / page) and four banks of data memory (16 bytes / bank). Two bits in the STATUS register, PA1:PA0, are used to manage the program memory pages. Two bits of the FSR register, bits 6 and 5, manage the data memory banks. We will call the FSR bit RP0 and the FSR bit RP1 (for Register Page 0 and 1). The naming of these bits RP1 and RP0 should not be confused with the similarly named bits in the PIC16CXX family (PIC16C64, PIC16C71, etc.). The RP bits for the PIC16CXX family are found in the STATUS register, as opposed to the FSR register for the PIC16C5X family. The use of these macros can be modified to support the PIC16CXX family. The program memory organization is shown in Figure 1 and the data memory organization is shown in Figure 2. To use the macros for the data memory, the data memory locations must be EQUated for the absolute address, and not the relative address in the bank. The relative address is the lower 5-bits of the data memory address. When the address of the data memory has the MSb (bit4) of the direct address cleared, or FSR cleared (for indirect addressing), the address 0h through 0Fh is accessed. That is, when accessing addresses 0h through 0Fh the bank selection (FSR) bits are ignored. This means that data memory addresses 'xxx0 xxxx'b access the data memory address 0xh (x is anywhere from 0 - F).
|
Title |
Title |
Date |
Size |
|
|---|---|---|---|---|
| AN586 Source Code - Macros for Page and Bank Switching 11.9 KB 09/24/2021 | AN586 Source Code - Macros for Page and Bank Switching | 09/24/2021 | 11.9 KB | Download |
Live Chat