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.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,859
Helped
4,854
Reputation
9,726
Reaction score
4,640
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
126,484
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.
 

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
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
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
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
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
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.
 

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
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
 

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
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
 

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
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?
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,859
Helped
4,854
Reputation
9,726
Reaction score
4,640
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
126,484
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.
 

cubanflyer

Full Member level 5
Joined
Jul 31, 2010
Messages
255
Helped
75
Reputation
152
Reaction score
71
Trophy points
1,308
Location
UK
Activity points
2,501
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top