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

Interrupts with internal and external code

I set the compiler to save the PSW and put it into source mode (4 byte frame) instead of
binary. Now when I load my program into the dscope it has the correct ljmp instructions to my
ISR's. I created an endless while loop(while(1);) in one of my subroutines(external code
space). When I run my code to this location it gets there fine, but when an interrupt occurs I
vector to the ISR and return to the code however when I return I do not actually execute any
instructions or stop at any breakpoints set. The trace shows that I just run through all of my
instructions until execution stops.
One other thing I noticed that the display of the call stack shows a different address than
what should be when an interrupt occurs. It seems to be off by 1 byte. Does this mean
anything the interrupt seems to come and go alright when it hits when I am in my main routine
(located in the same code segment as the ISR) But the stack addressing anomally applies.

Parents
  • Does anyone know what would cause the following:

    Interrupt returns to some new line of code that it puts into my source.

    My Code prior to interrupt

    address: FE002E ECALL stub2
    FE0032 SJMP #115 ; this is while (1) loop forever


    After the interrupt occurs I have
    FE002E ECALL stub2
    FE0030 RET
    FE0031 ??? 0xCE
    FE0032 SJMP #115

    Simulator generates an invalid instruction at address FE0030
    What is this new code and where did it come from Any ideas????

Reply
  • Does anyone know what would cause the following:

    Interrupt returns to some new line of code that it puts into my source.

    My Code prior to interrupt

    address: FE002E ECALL stub2
    FE0032 SJMP #115 ; this is while (1) loop forever


    After the interrupt occurs I have
    FE002E ECALL stub2
    FE0030 RET
    FE0031 ??? 0xCE
    FE0032 SJMP #115

    Simulator generates an invalid instruction at address FE0030
    What is this new code and where did it come from Any ideas????

Children
  • Are you sure about using HUGE memory model ?

    Which last instruction of your ISR and
    'stub2' function:
    - RETI/RET
    or
    - ERET


    It seems like non-simmetrical stack pointer's manipulating.
    For example, ECALL to function which finished with RET (but should be ERET).




  • Select "Options/C251 compiler", Dialog
    "C251 Compiler Options":
    - page "Object":
    [X] Save PSW1 in C251 interrupt code

    - page "Memory model":
    Code size limits: "Huge:64K functions, 16mb program size"



    In "Command Line Options String" should be:
    ".... I2 ROM(Huge) ...."

  • Thanks Sergey,

    Right now I am trying to link a group of functions together at address FF4000H
    and I am using the linker but the linker causes an error on my PC (PC fault) and it shuts down when I enter a long string into the command line.
    ie ?PR?Myfunc1?Myfile(0FF4000),?PR?Myfunc2?Myfile, etc....

    I have alot of functions. Does anyone know how I can work around this?????