Jump to content

How Do I Put Some Hex Constants In Rom At A Specific Location?

Recommended Posts


I have a boot loader that I wrote in assembler that just fits in the last 0x180 bytes of flash starting at location 0xfe80. I would like to include this in some C code projects but I know the inline assembly messes with the code so I just want to toss a bunch of hex constants into the hex file for programming. I tried the technique below and was able to simulate correctly but when I look at the .hex file, there is no 01020304 string in the file.


rom unsigned char BootCode[256] @ 0xf000 = {1,2,3,4};



When I tried this technique, I did see entries in the hex file at 0xf010:


unsigned char foo1() @ 0xf010





Is there a secret to get the first version to work?


Now that I think about it, I could just burn up a bit more space and just implement functions to erase, write and read a block of flash along with a little interpreter for the serial port and just shove it at the end of my code space using the foo1 function trick.


What I would like is a way for my little application to be able to have its firmware updated without using bootmode pins or doing a multi-step program of the part. I have a nice clean way to do this for pure assembly programs but would like to do this as a single hunk of C.


So, I guess never mind except it would be nice to figure out how to park some constants at a specific location.


I also tried putting the following in the function instead of return(5):

asm data 0x01,0x02,0x03,004


And did get my bytes in flash memory. The only problem is that they are converted to 16 bit values and a line feed was added to the end:



:0C says 12 bytes

F010 says starting at address 0xf010

00 says the type

0100 is a 16 bit low byte first 1

0200 is a 16 bit low byte first 2

0300 is a 16 bit low byte first 3

0400 is a 16 bit low byte first 4

0500 is a 16 bit low byte first 5

1200 is a 16 bit low byte first 0x12 (Line feed)

D3 is the sumcheck value.


Using 16-bit constants for asm data allows all the bytes to be written but with the order swapped and still gives the extra line feed.

asm data 0x0123,0x4567,0x89ab




I also tried "Hello" like the user manual says but the string is ignored.

asm data "Hello" results in a syntax error. asm data 1,2,"Hello" drops the hello.

Share this post

Link to post
Share on other sites

Hi Ted,


Just try using:

#pragma DATA 0x500,"Hello"

Just like you would to set config or eeprom data.






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.

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.


  • Create New...