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

aless2056

Newbie level 6
Joined
May 11, 2020
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
108
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?
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,247
Helped
377
Reputation
754
Reaction score
375
Trophy points
83
Activity points
13,504
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
 

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,927
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)
 

Dan1138

Junior Member level 3
Joined
Jan 30, 2018
Messages
30
Helped
6
Reputation
12
Reaction score
7
Trophy points
8
Activity points
279
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.
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top