how to access some bytes in bank 2/3 ?

General discussion on mikroPascal.
Post Reply
Author
Message
AlbrechtMe
Posts: 20
Joined: 03 Feb 2008 21:34
Location: Kiel, germany

how to access some bytes in bank 2/3 ?

#1 Post by AlbrechtMe » 30 Jun 2008 11:19

Hello, working with a pic16fxxx,

arrays can only be accessed by mE's compilers if they reside in Bank 0 or 1 (using RAM address up to $0FF).
If not, the letal message "Array has been split over two banks" arises and the tips in this forum tend to "try to use a pic18 instead".

Now I am missing assembler knowledge to use correct IRP (or whatever) settings for just reading or writing some bytes in the upper banks.

Isn't someone here so nice and could create two tiny little pieces of assembler code embedded in mP functions to access a range of bytes in bank 2 or 3?

I am dreaming of:

Code: Select all

procedure writeBank23(addr:byte; value:byte);

function readBank23(addr:byte):byte;
For a pic16f88 addr could then be in then ranges $10..$6F or $90..$EF

Kind regards and Thanks in advance.

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#2 Post by yo2lio » 30 Jun 2008 12:15

HI,

It's easy ... Use INDIRECT ADDRESSING !

IRP bit from STATUS register must be 0 for BANK 0/1 and 1 for BANK 2/3

Code: Select all

function ReadBank23(data_addr : byte) : byte;
begin
  STATUS.7 := 1;
  FSR := data_addr;
  result := INDF;
  STATUS.7 := 0;
end;

procedure WriteBank23(data_addr,value : byte);
begin
  STATUS.7 := 1;
  FSR := data_addr;
  INDF := value;
  STATUS.7 := 0;
end;
Last edited by yo2lio on 30 Jun 2008 12:55, edited 1 time in total.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

BaCaRdi
Posts: 236
Joined: 21 Feb 2008 02:19

#3 Post by BaCaRdi » 30 Jun 2008 12:41

You Rock Florin!

Thanks again.

-Marc
[size=109][color=Red][b]Error[/b]: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...[/color][/size]
[url=http://www.bacardiware.com]Information Underground[/url]

AlbrechtMe
Posts: 20
Joined: 03 Feb 2008 21:34
Location: Kiel, germany

how to access some bytes in bank 2/3 ?

#4 Post by AlbrechtMe » 30 Jun 2008 20:57

Whow! Well done. It works (of course...).

Thanks to Florin!

Post Reply

Return to “mikroPascal General”