PIC16F ASM Bank Selection

Thread Starter

massanetabr

Joined Jun 3, 2019
26
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?
 

Papabravo

Joined Feb 24, 2006
16,832
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?
I don't think it did things on it own, but it might have given a warning. It's been 6 or 7 years since I last used it.
 

Ian Rogers

Joined Dec 12, 2012
919
I think you were just VERY lucky... TRISB and PORTB are in different banks, so if you used pins as inputs, that is the default.

Unless you played with the serial port.. Or the option register, you may not have noticed..
 
Hi,

I use MPLAB v8.92 for the PIC16 as well as the PIC18 series and program in assembly.

If you select "Relocatable Code", the compiler will add two "BSF/BCF STATUS, RP1/RP0" in front of every register access to ensure that the correct bank is selected. This will increase the amount of flash space and execution time by the same proportion.

If you select "Absolute", then it's up to you to keep track of the BANK your in and set accordingly. This results in the smallest code size and fastest execution when needed.

However, I don't have any experience using a "C" compiler for the PIC16 or PIC18.

Happy programming!
Spitsnsparkin
 

Ian Rogers

Joined Dec 12, 2012
919
Hi,

I use MPLAB v8.92 for the PIC16 as well as the PIC18 series and program in assembly.

If you select "Relocatable Code", the compiler will add two "BSF/BCF STATUS, RP1/RP0" in front of every register access to ensure that the correct bank is selected. This will increase the amount of flash space and execution time by the same proportion.

If you select "Absolute", then it's up to you to keep track of the BANK your in and set accordingly. This results in the smallest code size and fastest execution when needed.

However, I don't have any experience using a "C" compiler for the PIC16 or PIC18.

Happy programming!
Spitsnsparkin
Cool..I didn't know that...
 
Top