This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with interrupts

Hiya guys, need a bit of help here

I have put this code in

-----------------------------------------
void noreturn (void) interrupt 1
{
send_serial("Timer0 Overflow");

}

------------------------------------------

but the target is not created when this code is in.

what could it be??

Parents
  • I'm just about positive that you can't use absolute code addresses in C.

    You would have to write an assembly file and add it to your project so that it is linked with your C code.

    In the assembly file, you'd have:

    .org 0x0000
    LJMP 0x1000

    .org 0x0003
    LJMP 0x1003

    etc.

    But, then you are still stuck adding this file to your project when compiling for the simulator and taking it out when compiling for use in HW.

    If you really want something "clean" how about this?:

    #define USING_SIMULATOR x
    // x=1 if "using simulator"
    // x=0 if using hardware

    #if (USING_SIMULATOR)
    #pragma iv (0x0000)
    #else
    #pragma iv (0xBF00)
    #endif

    You just change "x" depending on how you want it. I often write code that must be compiled differently for different situations and this is the best way to compile two different versions from the same source code.

Reply
  • I'm just about positive that you can't use absolute code addresses in C.

    You would have to write an assembly file and add it to your project so that it is linked with your C code.

    In the assembly file, you'd have:

    .org 0x0000
    LJMP 0x1000

    .org 0x0003
    LJMP 0x1003

    etc.

    But, then you are still stuck adding this file to your project when compiling for the simulator and taking it out when compiling for use in HW.

    If you really want something "clean" how about this?:

    #define USING_SIMULATOR x
    // x=1 if "using simulator"
    // x=0 if using hardware

    #if (USING_SIMULATOR)
    #pragma iv (0x0000)
    #else
    #pragma iv (0xBF00)
    #endif

    You just change "x" depending on how you want it. I often write code that must be compiled differently for different situations and this is the best way to compile two different versions from the same source code.

Children