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

RETI doesn't work

Hello,

I would like to realise a small OS for a microchip. I already have a running OS for the C167CR-LM and would like to also run it on a XC167CI. But the version for the Target XC167CI has a problem when returgin from a Interuptfunction.

Here is some code of my interruptfunction.

#define TSK_SW_TRAP_NR 0x30
#define TSK_SW_TRAP _trap_(TSK_SW_TRAP_NR)
...
IEN = TRUE;
TSK_SW_TRAP;
...

#pragma noframe
void trapScheduler(void) interrupt TSK_SW_TRAP_NR {
  static INT8U safedIEN;
  safedIEN = IEN;
  IEN = FALSE;

  #pragma asm
    push R0
    /*...*/
    push R15
  #pragma endasm

/*taskswitch*/

#pragma asm
    pop  R15
    /*...*/
    pop  R0
  #pragma endasm
  IEN = safedIEN;
}

The compiler than generates an assembler code like this:


;  IEN = TRUE;
BSET	IEN
;  TSK_SW_TRAP;
TRAP	#48
;


trapScheduler  PROC  INTERRUPT = 48
GLOBAL  trapScheduler
; FUNCTION trapScheduler (BEGIN  RMASK = @0x3FFF)

;push R0-R15
;taskswitch
;pop R15-R0

;  }
RETI
; FUNCTION trapScheduler (END    RMASK = @0x3FFF)
trapScheduler  ENDP
?PR?OSSCHEDULE  ENDS

My problem is that the RETI-Operation returns to the addresse 0x00004000 and the Debugger-Output-Windows says


*** error 65: access violation: addr=0x00004000


Does any one know what i did wrong? Do I have to change some options for the target or did I write a bug?

Best regards
Norbert

0