PIC: Dumb question re banksel

Status
Not open for further replies.

augustinetez

Active Member
The dumb question using a 16F628 as an example:-

OPTION is in banks 1 & 3 and TMR0 is in banks 0 & 2.

When using banksel for things like OPTION_REG or TMR0 and considering that these exist in two different sets of banks, which bank does it select?

I've been using banksel for these registers for a little while and not knowingly come across a problem doing it - just curious as to possible problems, if any.
 
When I programmed in Asm I kept away from banksel as it always produces two instructions when one or even none are needed. I now realise that it's irrelevant as the processor is so fast (fast enough to use C).
I know you can do it either way but why not use the option instruction (now deprecated) to set the option register?

Mike.
 
A quick simulation (MPLAB SIM) with this code:

Showed RP1 and RP0 bits of STATUS for TMR0 as 00 ( Bank 0) and for OPTION_REG was as 01 (Bank 1). I don't usually use the banksel directive, as I track what bank I am in to minimize switching when practical.
 
Mike, at some stage, I forget if it was an older PIC or a newer enhanced one, I kept getting an error message when trying to use the 'option' instruction, hence I've used option_reg ever since.

JP, thanks for that, answers the question.

I also do my best to group as much code as possible to minimise switching banks.
 
Mike, at some stage, I forget if it was an older PIC or a newer enhanced one, I kept getting an error message when trying to use the 'option' instruction, hence I've used option_reg ever since.
Are you saying that the option instruction no longer works? It was deprecated but I thought it had a few years before being removed.

Mike.
 
Are you saying that the option instruction no longer works? It was deprecated but I thought it had a few years before being removed.

Mike.
I thought it had been removed many years ago? - but I can't say I've ever tried it recently?. As far as I'm aware it was 'depreciated' last century?.
 
The 16F628 datasheet mentions it was left in to be compatible with 16C5X chips and should not be used for newer chips.

As to when it actually stopped working I don't know, I'm incapacitated at the moment, so might compile for a few different PICs tomorrow and see where it stops.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…