Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

BANKSEL AND PCLATH DOUBTS?

Status
Not open for further replies.

neelam29

New Member
dear all
can anyone please explain me two things....
firstly ,what does
Code:
BANKSEL ADCON1
mean? does it mean that the bank that contains ADCON1 i.e, bank1 is selected?
secondly ,what does
Code:
BCF PCLATH,3 
BCF PCLATH, 4
mean? does it mean that GOTO and CALL commands will operate beyond 2kB code

THANX

(for reference : nigel tutorial 11.1 )
 
neelam29 said:
dear all
can anyone please explain me two things....
firstly ,what does
Code:
BANKSEL ADCON1
mean? does it mean that the bank that contains ADCON1 i.e, bank1 is selected?
secondly ,what does
Code:
BCF PCLATH,3 
BCF PCLATH, 4
mean? does it mean that GOTO and CALL commands will operate beyond 2kB code

THANX

(for reference : nigel tutorial 11.1 )

There two completely different points there!.

First, 'Banksel', this is a macro that produces the required code to switch to the correct 'bank', this is where the GPR's (RAM) and special registers are held. This is 'bank selection', and is set by bits RP0 and RP1 in the STATUS register.

The second point is switching 'pages', this is program memory (essentially ROM), and it's arranged in 2Kb pages - the bits in PCLATH select which page you are using. This is 'page selection' and is set by bits in PCLATH, which are effectively the upper bits of the program counter PCL.

The two 'BCF PCLATH' lines clear the PCLATH bits, and mean the first page is selected. If you use a 16F628 it only has 2Kb of program memory, so paging doesn't apply!.

It's all explained in the datasheets!.
 
BANKSEL is not a macro but rather a assembler/linker directive. You can find its definition in the MPASM help file, under the Directive section.

A macro generates the same code each time when used. However, the BANKSEL directive will generate different codes depending on the PIC family used.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top