Is there a way to limit ram and program locations in XC8?

Thread Starter

geekoftheweek

Joined Oct 6, 2013
692
I have a working system loop in assembly that sets up basic communications, blinks a LED, and can reprogram memory outside of the system program area (usually starting at 800h). When the right combinations are sent by I2C to the PIC it will call address 800h which is a goto to the "application setup" routine. Once initialized the system loop will then call 808h which is a goto to the "application loop". Doing it this way makes it possible to reprogram the application program memory without having to update addresses in the system loop every time the program changes. Another right combination by I2C and the system loop will reprogram the application area.

An rough example of the system program. 0h - 7ffh
Code:
setup oscilator, timers, I2C,  and whatever else

_system_loop
    handle i2c -- call ___application_start_ptr,  ___application_stop_ptr, and whatever else as needed  to reprogram,  move data, etc.
    if application initialized and running call ___application_loop_ptr
    handle timer to blink led
   goto _system_loop
Then in application memory 800h - end of program memory space
Code:
___application_start_ptr
    goto __application_start
___application_stop_ptr
    goto __application_stop
___applcation_loop_ptr
    goto __application_loop

__appllciation_start
    change led blink rate
    set system flag to show application started
    do application related setup
    return

__application_stop
    change led blink rate
    set system flag to show application stopped
    do application related shutdown
    return

__application_loop
    do application related tasks
    return
I was wondering if there is a way to implement a similar program in XC8. I'm thinking it would need to limit the compiler's usage of ram for the C runtime stuff like stacks and what not for both the system program and the application program. I currently define all memory locations so that the system program and application program use the same data for everything. I would have to carry over that practice also.

More or less the main two questions I have are:
Is it possible to define where the functions are located in program memory with XC8?
Is there a way to limit XC8 to only using ram from 100h - 200h (or whatever works best) for the C runtime and have the rest of ram reserved for how the program itself uses it?

Although I'm rather fond of assembly this is one of those projects C would make so much easier in the end just to eliminate a whole lot of translating C to assembly to get USB up and running.
 

BobTPH

Joined Jun 5, 2013
3,690
There is probably a combination of compiler and linker directives that will do that. Have you tried the user guide?

Bob
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
692
That would make sense Bob... of course I didn't. I does look like it should be fairly easy to get things the way I want them. I guess I'll be back if I run in to trouble..
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
692
Thanks @nsaspook. After a quick glance at the link it seems like it's going to be easier than I imagined. Once I get a working program I'll start to tweak things and see what happens.

Unfortunately I spent too much of my weekend avoiding house work and household projects so it will be a few days before I can get back to this... my project list to available time ratio is way heavy on the wrong end.
 
Top