PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 06, 2007 12:37 pm |
|
|
Quote: |
There are a few things I don't understand about this - I assume I use the
write_program_memory() function - but how do I know where my code
ends and where the empty memory begins. |
You need to tell the compiler to reserve a range of Flash memory
addresses for your use. Then the compiler won't use them for code.
You can do this by using the #org statement. See the Ex_logger.c file
for an example:
Quote: | c:\program files\picc\examples\Ex_Logger.c |
Near the start of that file, there's a large number of #org statements
buried within #if and #elif statements. You don't have to worry about
that. That's only for the 16F-series PICs, which have ROM pages.
You're using an 18F, so this code is all you need to define the buffer:
Code: |
#define BUFFER_SIZE 4096 // in bytes
#define PROGRAM_MEMORY_SIZE getenv("PROGRAM_MEMORY")
#define BUFFER_END PROGRAM_MEMORY_SIZE-1
#define BUFFER_START (PROGRAM_MEMORY_SIZE-BUFFER_SIZE)
#org BUFFER_START, BUFFER_END {}
|
|
|