|
|
View previous topic :: View next topic |
Author |
Message |
joe06 Guest
|
Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 8:07 am |
|
|
Hi All,
I'm trying to compile my 16F877 bootloader at a fixed address, my bootloader is composed of several functions, declared as follow :
#define BOOTLOAD_START_ADR 0x1F00
// bootloader prototypes functions
#separate void Boot_Loader(void);
#separate void Write_Byte_Int_Mem(void);
#separate void Read_Byte_Int_Mem(void);
#org BOOTLOAD_START_ADR
void Boot_Loader(void)
{
BYTE temp, temp1;
TRISB = 0B11011100; // Port B IOs
TRISC = 0B10101000; // Port C IOs
TRISD = 0B11000000; // Port D IOs
Call to others functions from this one
....
}
#org BOOTLOAD_START_ADR
void Write_Byte_Int_Mem(void)
{
....
}
#org BOOTLOAD_START_ADR
void Read_Byte_Int_Mem(void)
{
....
}
There are ohter functions not shown above, all the bootloader code is located into the last 256 bytes of memory.
The ORG directive does the above job, my problem is that I cannot succeed to compile the Main bootloader function (entry point : Boot_Loader()), at the adress 0x1F00, the compiler places it at address 0x1F87 ... how can I force this fucntion to be compiled at the begiining of the bootloader area ? I mean at 0x1F00 instead of between 0x1F00 and 0x1FFF ?
I've tryed removing #separate, nothing changed ..
Any help would be greatly appreciated ...
joe
___________________________
This message was ported from CCS's old forum
Original Post ID: 11785 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 12:44 pm |
|
|
:=Hi All,
:=I'm trying to compile my 16F877 bootloader at a fixed address, my bootloader is composed of several functions, declared as follow :
-------------------------------------------------------------
You have to follow the example in the manual.
Do it like this:
#define BOOTLOAD_START_ADR 0x1F00
#define BOOTLOAD_END_ADR 0x1FFF
#org BOOTLOAD_START_ADR, BOOTLOAD_END_ADR
void Boot_Loader(void)
{
// Put code here.
}
#org BOOTLOAD_START_ADR
void Write_Byte_Int_Mem(void)
{
// Put code here.
}
#org BOOTLOAD_START_ADR
void Read_Byte_Int_Mem(void)
{
// Put code here.
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11800 |
|
|
joe06 Guest
|
Re: Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 12:52 pm |
|
|
This is what I started to do.
how to declare the functions prototypes used in the bootloader, as separate ? because the rest of the program has to access to these common functions
All my bootloader functions are located into the last 256 bytes, but CCS changed the order !
help !
:=:=Hi All,
:=:=I'm trying to compile my 16F877 bootloader at a fixed address, my bootloader is composed of several functions, declared as follow :
:=-------------------------------------------------------------
:=
:=You have to follow the example in the manual.
:=Do it like this:
:=
:=#define BOOTLOAD_START_ADR 0x1F00
:=#define BOOTLOAD_END_ADR 0x1FFF
:=
:=#org BOOTLOAD_START_ADR, BOOTLOAD_END_ADR
:=void Boot_Loader(void)
:={
:=// Put code here.
:=}
:=
:=#org BOOTLOAD_START_ADR
:=void Write_Byte_Int_Mem(void)
:={
:=// Put code here.
:=}
:=
:=#org BOOTLOAD_START_ADR
:=void Read_Byte_Int_Mem(void)
:={
:=// Put code here.
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11801 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 1:39 pm |
|
|
:=This is what I started to do.
:=how to declare the functions prototypes used in the bootloader, as separate ? because the rest of the program has to access to these common functions
:=All my bootloader functions are located into the last 256 bytes, but CCS changed the order !
:=help !
---------------------------------------------------------
It won't change the order of the first function.
That should be the only one you care about. The first
function should be the entry point for the bootloader.
The example I gave you will put the first function
at 0x1F00. I tested it, before I posted the answer.
If you have questions about how to declare the helper
functions as separate, I've posted a complete example
of a bootloader in the past.
Here's the flash.h code, which shows how to declare
the helper routines as separate.
FLASH.H
<a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1572.html</a>
FLASH.C
<a href="http://www.pic-c.com/forum/general/posts/1571.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1571.html</a>
Here are links to all of the routines.
<a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/7604.html</a>
<a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1572.html</a>
<a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/7604.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11803 |
|
|
joe06 Guest
|
Re: Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 2:57 pm |
|
|
thanks !
I've just compiled using an intermediate function bootloader_entrypoint(), that calls the main bootloader function
the entry point is now at ox1f00
just an additional question, why did you reserve 0x0B bytes
just for the entry point, which requires only 4 bytes ?
#define NORMAL_SEGMENT_START 0x1e00
#define NORMAL_SEGMENT_END 0x1e0b
#org NORMAL_SEGMENT_START, NORMAL_SEGMENT_END AUTO=0
void flash_normal_entry_point(void)
{
flash_firmware(FLASH_NORMAL_MODE); // this requires 4 bytes, not 0xB bytes
}
:=:=This is what I started to do.
:=:=how to declare the functions prototypes used in the bootloader, as separate ? because the rest of the program has to access to these common functions
:=:=All my bootloader functions are located into the last 256 bytes, but CCS changed the order !
:=:=help !
:=---------------------------------------------------------
:=It won't change the order of the first function.
:=That should be the only one you care about. The first
:=function should be the entry point for the bootloader.
:=The example I gave you will put the first function
:=at 0x1F00. I tested it, before I posted the answer.
:=
:=If you have questions about how to declare the helper
:=functions as separate, I've posted a complete example
:=of a bootloader in the past.
:=
:=Here's the flash.h code, which shows how to declare
:=the helper routines as separate.
:=
:=FLASH.H
:= <a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1572.html</a></a>
:=
:=FLASH.C
:= <a href="http://www.pic-c.com/forum/general/posts/1571.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/1571.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1571.html</a></a>
:=
:=Here are links to all of the routines.
:= <a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/7604.html</a></a>
:=
:=
:= <a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/1572.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1572.html</a></a>
:=
:= <a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/7604.html</a></a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11806 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Compiling a function to a fixed address : ORG |
Posted: Mon Feb 17, 2003 3:27 pm |
|
|
:=thanks !
:=I've just compiled using an intermediate function bootloader_entrypoint(), that calls the main bootloader function
:=the entry point is now at ox1f00
:=just an additional question, why did you reserve 0x0B bytes
:=just for the entry point, which requires only 4 bytes ?
-----------------------------------------------------------
I originally used PCM vs. 2.732, to write that program.
It used 11 bytes.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11809 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|