Continue to Site

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.

Implementing Table Read and Write in PIC18F4550

Status
Not open for further replies.

bliscar

Newbie level 3
Joined
Jun 2, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
Hi,
Anyone knows here how to implement Table Read and Write in PIC18F4550 using MPLAB-X or MPLAB IDE as the environment and C18 Compiler...
 

you need to use the 'rom' attribute while defining your pointer and #pragma romdata if it's a table...

for example a table in flash memory (two examples, one table at 0x5000 and other at 0x5200):
Code:
#pragma romdata PRODS=0x5000
rom int Productos[]= {70,50,50,100,100,150,20,50,60};

#pragma romdata PRODS2=0x5200
rom char Prods[][2]={
{0,0x01},
{1,0x02},
{2,0x03},
{3,0x01},
{3,0x02},
{4,0x02},
{4,0x03},
{5,0x01},
{5,0x02},
{5,0x03},
{6,0x80},
{7,0x80},
{7,0x80},
{7,0x80},
{8,0x80},
{8,0x80},
{8,0x80},
{8,0x80}};

//to finnish pragma code!
#pragma code

and use it like a normal table

Code:
...

sb1 = Prods[3][0];
sb2 = Prods[3][1];
..
//you know, right?



if you need you can define the pointer externally as:
Code:
extern rom int Productos[];
extern rom char Prods[][2];

if you want a char pointer to any part of the flash memory,
define a pointer
Code:
rom char* maPointer;

and use it as you need

Code:
...
maPointer = 0x5000; //points to some part of the memory

bv = (*maPointer); //read address 0x5000 !!!!

maPointer++; //now points to 0x5001;

//etc
...
//and also
...
(*maPointer) = someValue; //prefills page byte, read the datasheet for actual write in memory!!!

it also works with the table version!

Code:
Prods[10][0]=newValue; //prefills page byte, again please read the datasheet for actual write... even it's more complicated with a table... do it with a known pointer
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top