Jump to content
Andrew Leiper

Storing Data In Rom At A Fixed Address

Recommended Posts

Hi there,

 

I am trying to store some data in rom at a fixed location so my bootloader knows where to access it.

 

I tried doing this:

rom char *rUnitType @ 0x1000 = { 0x99, 0x88, 0x77, 0x66, 1, 2, 3, 4, 5, 6, 7,8 , 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};

 

...but although the data is in ROM, it is not at 0x1000.

 

Is there a way of doing this in C ? Do I perhaps need to link in an object file created in assembler somehow ?

 

(Sourceboost V7.10, PIC18F)

 

Hope you can help.

 

Andy Leiper

IET Ltd

Share this post


Link to post
Share on other sites

Hi there,

 

OK, after a bit of jiggery pokery I have discovered that I can do this:

 

#define NUM1 0x2211

#define NUM2 0x4433

void romfunc(void) @ 0x1000

{

asm {

data NUM1

data NUM2

}

}

 

This works except that it leaves a return instruction at the end of the data. If there is a better way of doing it though, please let me know.

 

Thanks,

 

Andy Leiper

IET Ltd

Share this post


Link to post
Share on other sites

Andrew Leiper,

OK, after a bit of jiggery pokery I have discovered that I can do this:

 

#define NUM1 0x2211

#define NUM2 0x4433

void romfunc(void) @ 0x1000

{

asm {

data NUM1

data NUM2

}

}

 

This works except that it leaves a return instruction at the end of the data. If there is a better way of doing it though, please let me know.

Another option is to use #pragma DATA (see BoostC user manual on how to use this), but I think the method you demonstrate above is probably the neatest and the most flexible in terms of data types that can be readily stored.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hi Dave,

 

Thanks for the suggestion. For some reason though the line below didn't seem to put any data in to ROM that I could see.

 

#pragma DATA 0xBC00 0x11,0x22,0x33,0x44

 

Not sure if it is a bug or I was doing something wrong but I'll continue with my function method for now.

 

Cheers,

 

Andy Leiper

IET Ltd

Share this post


Link to post
Share on other sites

For some reason though the line below didn't seem to put any data in to ROM that I could see.

 

#pragma DATA 0xBC00 0x11,0x22,0x33,0x44

 

Not sure if it is a bug or I was doing something wrong but I'll continue with my function method for now.

 

 

Whether it is a writing error, I do not know, but there are no comma after the address?

 

So that line should be:

 

#pragma DATA 0xBC00, 0x11, 0x22, 0x33, 0x44

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...