From: <pa...@li...> - 2003-06-26 15:48:10
|
Hi all the ML, may be i'm doing some mistake since i'm really not a C guru, but please give a look at this problem... Compiling the following isr_test.c file and searching in the generated asm file, it seems that SDCC generates a wrong code in the start of the interrupt routine that makes it not working ( GOTO END_OF_INTERRUPT+1 look at the extracted part of isr_test.asm file down here). Searching in the sdcc source, i see that the code is generated by gen.c source in /sdcc/src/pic directory at the line 2697: addpCode2pBlock(pb,newpCode(POC_GOTO,newpCodeOp("END_OF_INTERRUPT+1",PO_STR) )); emitpcodeNULLop(POC_NOP); emitpcodeNULLop(POC_NOP); emitpcodeNULLop(POC_NOP); Commenting out these four lines and rebuilting SDCC seem to generate working code again...at least i hope it :-) Please give it a try and let me know. Bye, Onny. ///// Start of isr_test.c ///// #include <p16f877.h> typedef unsigned int word; word at 0x2007 __CONFIG = _CP_OFF & _WDT_OFF & _BODEN_ON & \ _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & \ _LVP_OFF & _DEBUG_OFF & _CPD_OFF; void isr() interrupt 0 { TMR2IF=0; // just for make it generate something... } void main(void) { PORTA=255; } ///////////////////////////////////////////////// END OF isr_test.c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extracted from the genarated isr_test.asm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;-------------------------------------------------------- ; reset and interrupt vectors ;-------------------------------------------------------- STARTUP code goto __sdcc_gsinit_startup nop nop goto __sdcc_interrupt ;-------------------------------------------------------- ; initialization and interrupt code ;-------------------------------------------------------- code_init code 0x10 __sdcc_gsinit_startup: ;*** ; pBlock Stats: dbName = D ;*** ;; Starting pCode block pagesel _main goto _main __sdcc_interrupt: ;*** ; pBlock Stats: dbName = I ;*** ;entry: _isr ;Function start ; 0 exit points ;; Starting pCode block _isr ;Function start ; 0 exit points ;#CSRC isr_test.c 11 ; void isr() interrupt 0 { GOTO END_OF_INTERRUPT+1 ;;; <------------- Here's the problem... NOP NOP NOP MOVWF WSAVE SWAPF STATUS,W CLRF STATUS MOVWF SSAVE ;#CSRC isr_test.c 12 ; TMR2IF=0; // just for make it generate something BCF (_TMR2IF >> 3), (_TMR2IF & 7) CLRF STATUS SWAPF SSAVE,W MOVWF STATUS SWAPF WSAVE,F SWAPF WSAVE,W END_OF_INTERRUPT RETFIE goto $ <-------------- The program remains here!!!!! (END_OF_INTERRUPT + 1) ;-------------------------------------------------------- ; code ;-------------------------------------------------------- code_isr_test code ;*** ; pBlock Stats: dbName = M ;*** ;entry: _main ;Function start ; 2 exit points ;has an exit ;; Starting pCode block _main ;Function start ; 2 exit points ;#CSRC isr_test.c 19 ; PORTA=255; MOVLW 0xff MOVWF _PORTA RETURN ; exit point of _main end |