Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F ASM Bank Selection

Status
Not open for further replies.

aless2056

Member level 1
Joined
May 11, 2020
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
338
Since when I started doing some things using uc, first the pic 16f628, then the 16f877 I never selected the bank before accessing a registered one.

Did MPlab Ide 8.92 always fix it on its own or everything I have done so far has a terrible bug, but at first it is working?
 

If you wrote in C then the compiler would have handled this for you.
In assembler you need to use the BANKSEL 'instruction'. Depending on what SFRs you referenced and how much data memory you used, you might have been lucky if everything fitted into Bank 0.
By the way, MPLab 8.9 is very old as are the MCUs you reference.
Anyway, it would not be the IDE that 'always fix(sic) it' as that is only the editor and control mechanism to the compiler/assembler. Hence my first comments.
Susan
 

Since when I started doing some things using uc, first the pic 16f628, then the 16f877 I never selected the bank before accessing a registered one.

Did MPlab Ide 8.92 always fix it on its own or everything I have done so far has a terrible bug, but at first it is working?
Can you post your codes that we can explain it , Some time all the codes that you have written in default bank (0)
 

Since when I started doing some things using uc, first the pic 16f628, then the 16f877 I never selected the bank before accessing a registered one.

Did MPlab Ide 8.92 always fix it on its own or everything I have done so far has a terrible bug, but at first it is working?
It is almost impossible to create a useful assembly language application for a PIC16F628 or PIC16F877 without knowing how to select bank 1 to set and clear bits in the special function registers that control when a GPIO port pin is an input or an output bit.

To be specific the Microchip assembler DOES NOT select the appropriate bank for registers. This must be done explicitly in the assembly language source code.

The most convienient way is to use the assembler directive BANKSEL where the parameter is the full address of the register. This directive causes the assembler to insert the opcode required to set the bank select.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top