need help CC5x pic16f Overlapping code

Discussion in 'Programmer's Corner' started by m3atwad, Feb 1, 2010.

  1. m3atwad

    Thread Starter New Member

    Feb 1, 2010
    5
    0
    I am writing a C bootloader using the CC5x c compiler for pics (pic in use is a 16f690) I am trying to write some commands to the reset vector so the program will jump to my bootloader at the top of memory space. The directive is #pragma cdata[], but I am getting this error "overlapping code at adress 0x00". I have tried this with other c compilers (hight tech c compiler) and I can't figure out how to write to that memory space with this one either. From what i've found so far it sounds like it could be a linker problem, but i'm not sure. Basically, how to I write a goto command to the reset vector with a pic c compiler? Is it protected or already written to and is that why I can't write to it?
     
  2. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    Typically the compiler will use the reset vector to initialise stuff, like clearing memory and copying any initialised variable data from ROM to RAM, then jump to the user program main();
     
  3. m3atwad

    Thread Starter New Member

    Feb 1, 2010
    5
    0
    yea that is 100% correct. looking at the program memory it puts a goto command there that points to memory location 001h. I can't figure out how to force it to put my goto command there instead though. I've been looking though the compiler manual, but haven't come up with much. Is there some kind of command or optimizing option i need to modify?
     
  4. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    If you write in C, you need the compiler to do it's stuff.

    Put your code in main() as it needs.

    I think your only other option is to write it in assembler so the only code in the chip is what you supply.
     
  5. aashitech

    New Member

    Feb 20, 2009
    1
    0
    Add below code at very start of main(),0x??? is to be replaced by address where you want to jump...but remember ....please add a "ret" instruction at end of the code you want to jump at because its a "call" not a "goto" at your code ...hope that helps.....

    void main()
    {
    #asm
    DW __CALL(0x???)
    #endasm

    ..........
    ...............
    .....................
    .......................

    }
     
Loading...