Create a table with more than 256 byte of data

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
jeflores
Posts: 12
Joined: Fri Apr 06, 2012 7:37 am

Create a table with more than 256 byte of data

Post by jeflores »

Create a table with more than 256 byte of data, micro pic18F45K20, Using (TBLRD *).

If u can help me with an example would be of great help.
Thanks

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Create a table with more than 256 byte of data

Post by Benj »

Hello,

The easiest way to do this on a 8-bit PIC is to create multiple arrays of 256 bytes and then have a handler macro to decode the address and decide which array to use.

if (Address > 256)
{
Address = Address - 256
Data = Array1[Address]
}
else
{
Data = Array0[Address]
}

jeflores
Posts: 12
Joined: Fri Apr 06, 2012 7:37 am

Re: Create a table with more than 256 byte of data

Post by jeflores »

Hello thanks for replying, I create multiple tables and as an image I had to do a lot. when I compile the project is a single table, use the instruction (TBLRD *) to read.
GOTO label6
MOVLW UPPER( label27 )
MOVWF TBLPTRU
MOVLW HIGH( label27 )
MOVWF TBLPTRH
MOVLW LOW( label27 )
MOVWF TBLPTRL
label6
MOVF __rom_get_00000_1_romAddr+D'2', W, 1
ADDWF TBLPTRL, F
BTFSC STATUS,C
INCF TBLPTRH, F
BTFSC STATUS,C
INCF TBLPTRU, F
TBLRD*
MOVF TABLAT, W

RETURN
label7
DW 0x0000
DW 0x0000
DW 0x0000
DW 0x5F06
DW 0x0006
DW 0x0307
DW 0x0700
DW 0x2403
DW 0x247E

how to do the reading, which made ​​it impossible for me to create it's like bigger than 256 bytes.
try the # pragma DATA, but I can only put one line and overflows if many characters.

any idea how to tell the compiler to make the data without me errror?
I speak Spanish, I apologize if it is not very clear trduccion, google helped me

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Create a table with more than 256 byte of data

Post by Benj »

Hello I think the problem is due to the PIC's memory being placed into banks. Each bank of RAM is 256 bytes wide and therefore you cannot have a array that spans across multiple banks.

I think the assembler code should work but you may have to add the bank switching instructions in to allow you to access the other locations.

The C code and Flowcode will automatically do the bank switching for you on the example I posted earlier so you need not worry about having to do any of this.

It should be possible to create macros to read and write to the data array using multiple arrays of 256 bytes from a single address variable.

jeflores
Posts: 12
Joined: Fri Apr 06, 2012 7:37 am

Re: Create a table with more than 256 byte of data

Post by jeflores »

Thanks, so I will.

Post Reply