Pic16f877a

stahta01

Joined Jun 9, 2011
133
... Instead of using the the bank0 and bank1 macros. It is better to use the banksel directive in MPLAB ASM. ...
I agree the OP could remove the directives (UDATA_SHR) that uses shared memory and replace them with UDATA and then add many banksel directives [before the variables are used]. Since the program used Shared Memory so much, I would guess it did not use banksel or bank0/1 Macros. But, It does use Bank0/1 Macro I found out searching the files.

When, I was a Student (I did not know about banksel) I wrote my own inc file with improved BANK0 and BANK1 macros. I think my solution is better than using banksel; but, it requires customizing the inc file. Edit: I was able to compile with out warning (and I did not use errorlevel -302). This is just not worth the effort; except in a few cases.

Edit: The program defines Bank0 and Bank1 Macros; and it seems to use them; used AstroGrep to search the folders.

Tim S.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
When, I was a Student (I did not know about banksel) I wrote my own inc file with improved BANK0 and BANK1 macros. I think my solution is better than using banksel; but, it requires customizing the inc file
No big deal but I do not agree. Using the banksel directive will make the code more portable than using a macro in the include file. But anyway the PIC MCU family is very big. And the MCUs do have minor differences. I do not know the 16f871 very well. But I doubt it 100% compatible then it comes to functionality and how the bits in the SFRs are used.
One last tip to OP. Remember to use the pagesel directive if the code go outside the lower 2K segment in the code memory. If you are programming in assembler
 

stahta01

Joined Jun 9, 2011
133
No big deal but I do not agree. Using the banksel directive will make the code more portable than using a macro in the include file. But anyway the PIC MCU family is very big. And the MCUs do have minor differences. I do not know the 16f871 very well. But I doubt it 100% compatible then it comes to functionality and how the bits in the SFRs are used.
One last tip to OP. Remember to use the pagesel directive if the code go outside the lower 2K segment in the code memory. If you are programming in assembler
I agree banksel is more portable; but, my custom BANK commands was less error prone. It is about a wash which one requires more work; the smaller the project the more work my custom BANK commands.

If I was porting a large or confusing project, I would use my custom BANK commands. Writing a large project from scratch likely use banksel because I would want it to be portable. (Edit: I would more likely just write it in C for real portability. ) Edit: Since, I hate turning off warnings "errorlevel -302" using my custom BANK seems so much better to me as a programmer.

FYI: The asm project under discussion in this thread has issues with porting using banksel. Because the person who wrote the code used the same define label for TRIS and PORT registers; just set the bank different. My custom BANK labels allowed me to see this issue without examining the code line by line.

Tim S.
 
Last edited:
Top