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.

PIC16F72 Bank Selection?

Status
Not open for further replies.

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
hello friends.
Please can you provide me code that how i can select bank0 , bank1, bank2, bank3 in pic16f72 using assembly language? i dont want to use banksel system plzz.
 

Just set (bsf) or clear (bcf) the bank selecting bits in the STATUS register.
'banksel' is far safer though - and all it does is sets those bits automatically for you.

Brian.
 

Is below is authentic coding?
i dont want to use compiler instructions and dont want to select banks here and there so i directly use the address of register location? or i should need to use bank selection?

org 0x00
clrf 0x9f ;all digital input output
clrf 0x86 ;tricb
movlw B'10101010'
movwf 0x06 ;portb
end
 

What's wrong with bank selection? It's safe and simple. And, if you're programming in assembly for 16F72, you probably won't be using another compiler besides 16F72.
 

Hi,

Is there a point to coding like this?

You might as well go back 30 years and use machine code, thats about as elementary as you can get.

They developed Assembler with system register names and directive like banksel to make coding easier
 

Hi,

Is there a point to coding like this?

You might as well go back 30 years and use machine code, thats about as elementary as you can get.

They developed Assembler with system register names and directive like banksel to make coding easier

Well said!

@ d@nny,
May I know the reason for you choosing to avoid banksel?
Plus, as said by wp100, you should use the register names while coding instead of the addresses. For this, all you need to do is include the header file and use the register names (in capital letters).

Code:
include "P16F72.inc"

Then, just use the registers:

Code:
PORTB
PORTA
CCP1CON
ADCON1

Hope this helps.
Tahmid.
 

actually i know this.
i want to demonstrait complere 16F72 instruction in .asm . so i decide to use portb equ xxx. but u r right. so thank u so much.

---------- Post added at 17:35 ---------- Previous post was at 17:08 ----------

What is the danger if i dont select banks? can iaccess register in all banks just through address but not banksel as below i just access them with portb trisc etc? If yes then why banksel is there?

include "P16F72.inc"
__config _WDT_OFF & _PWRTE_ON
org 0x00
clrf ADCON1
clrf TRISB
movlw B'10101010'
movwf PORTB
end
 

No you can't. If it was possible, there wouldn't be any bank switching. There wouldn't be any banksel then.

You can't do it in PIC 16F72.

Hope this helps.
Tahmid.
 

but trisc and adcon1 is in bank 1 and portb in bank 0. the assembler mpasm is not giving any error and making .hex file. i am using
 

NO NO here is the file of idx. actully it creating .hex file but also saying ensure bank.



make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `D:/MPLABX/Projects/My COMSATS LCD.X'
make -f nbproject/Makefile-default.mk dist/default/production/My_COMSATS__LCD.X.production.hex
make[2]: Entering directory `D:/MPLABX/Projects/My COMSATS LCD.X'
"D:\MPLABX\mpasmx\mpasmx.exe" -q -p16f72 -l"build/default/production/comsatslcd.lst" -e"build/default/production/comsatslcd.err" -o"build/default/production/comsatslcd.o" comsatslcd.asm
Message[302] D:\MPLABX\PROJECTS\MY COMSATS LCD.X\COMSATSLCD.ASM 4 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\MPLABX\PROJECTS\MY COMSATS LCD.X\COMSATSLCD.ASM 5 : Register in operand not in bank 0. Ensure that bank bits are correct.
"D:\MPLABX\mpasmx\mplink.exe" -p16f72 -w -z__MPLAB_BUILD=1 -odist/default/production/My_COMSATS__LCD.X.production.cof build/default/production/comsatslcd.o
MPLINK 4.41, Linker
Device Database Version 1.5
Copyright (c) 1998-2011 Microchip Technology Inc.
Errors : 0

MP2HEX 4.41, COFF to HEX File Converter
Copyright (c) 1998-2011 Microchip Technology Inc.
Errors : 0

make[2]: Leaving directory `D:/MPLABX/Projects/My COMSATS LCD.X'
make[1]: Leaving directory `D:/MPLABX/Projects/My COMSATS LCD.X'

BUILD SUCCESSFUL (total time: 2s)
Loading D:/MPLABX/Projects/My COMSATS LCD.X/dist/default/production/My_COMSATS__LCD.X.production.hex...
Loading completed

---------- Post added at 17:47 ---------- Previous post was at 17:46 ----------

wot do u think should microchip consider this error and not making hex file as above errors 0 errors 0?
 

It does say Errors 0 !

The Message[302] lines are warnings, not errors, and they are telling you to check the banks are selected properly.

You MUST use bank selection, it isn't an oversight by Microchip, it's a way of fitting enough register numbers into the available instruction space. I'm not sure exactly what will happen if you use the addresses directly but I would guess the top address bits would be ignored and everything would map into bank 0.

Brian.
 

Another reason for using the register names etc, when you look at the code in 12 months time it makes it easier to remember what you were doing in it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top