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; }
; 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
Is it possible that the problem causes the memory model. The program for the C167CR-LM has the option "TINY" in the memory model which doesn't use segmentation. But I now want to use "SMALL" which already uses segmentation. So the trap-function pushes CSP to the Stack and RETI pops it (theoretically). But do I have to change something on the code?? Best regards Norbert
Most likely yes (depends on the implementation of the scheduler) since RETI changes behaviour in SEGMENTED mode. Maybe source code of RTX-Tiny in the folder: \Keil\C166\Rtx_Tiny\RTX166T.A66. Reinhard