From: SourceForge.net <no...@so...> - 2004-05-26 11:33:12
|
Bugs item #960614, was opened at 2004-05-26 09:22 Message generated for change (Settings changed) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=960614&group_id=599 Category: msc51(8051) target Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: tony_pemberton (tonypemberton) Assigned to: Nobody/Anonymous (nobody) Summary: Interrupt carry bit problem Initial Comment: I am a newbie to SDCC, so perhaps I am missing something. Please also see PS below. I seem to be having difficulties with Timer Interrupts in SDCC running on my Silabs C8051F310. It seems that optimisation stops the PSW being pushed/popped onto the stack. As a result, an integer operation causes the carry bit to change state and the program runs wild until a Flash violation causes a reset. The C code for Timer2_ISR is as below. //----------------------------------------------------- ------------------------ // 0x2b Timer2_ISR Interrupts every 15ms //----------------------------------------------------- ------------------------ // void Timer2_ISR (void) interrupt TF2_VECTOR critical { displayButtonHoldDownTime++; TF2H = FALSE; // clear Timer2 overflow flag TF2L = FALSE; // clear Timer2 overflow flag } The resulting ASM code is as below. C:/Program files/SDCC/source/TT_PROCS.C:318: void Timer2_ISR (void) interrupt TF2_VECTOR critical ; ----------------------------------------- ; function Timer2_ISR ; ----------------------------------------- _Timer2_ISR: push acc push dpl push dph setb c jbc ea,00103$ clr c 00103$: C$TT_PROCS.C$320$1$1 ==. ;C:/Program files/SDCC/source/TT_PROCS.C:320: displayButtonHoldDownTime++; ; genPlus mov dptr,#_displayButtonHoldDownTime movx a,@dptr add a,#0x01 movx @dptr,a inc dptr movx a,@dptr addc a,#0x00 movx @dptr,a C$TT_PROCS.C$321$1$1 ==. ;C:/Program files/SDCC/source/TT_PROCS.C:321: TF2H = FALSE; // clear Timer2 overflow flag ; genAssign clr _TF2H C$TT_PROCS.C$322$1$1 ==. ;C:/Program files/SDCC/source/TT_PROCS.C:322: TF2L = FALSE; // clear Timer2 overflow flag ; genAssign clr _TF2L 00101$: mov ea,c pop dph pop dpl pop acc C$TT_PROCS.C$323$1$1 ==. XG$Timer2_ISR$0$0 ==. reti ; eliminated unneeded push/pop psw ; eliminated unneeded push/pop b The version of SDCC is as below. C:\Program Files\SDCC\bin>sdcc -v SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51 /ds400/hc08 2.4.1 (May 19 2004) (MINGW32) I note that the serial interrupt does save the PSW, but others do not even if they are dummy for later use. Is there a pragma or other workaround for this problem? I guess I could code the routine in assembler but that rather defeats the object of using C. Best regards, Tony Pemberton PS Since my original post in the forums I have been doing some further work. I have put the original message in the bug list as requested. I found I was not using external storage declarations so was getting multiple references to variables. This was fixed, but is not really germane to the issue. I also tried using reg bank 1 and this fixed the problem - for now. I do not use #pragma's at all in my current code. The batch file I use is as:- cd "C:\Program files\SDCC\bin SDCC -c --no-xinit-opt --debug "C:\Program files\SDCC\source\TT_INIT.C SDCC -c --no-xinit-opt --debug "C:\Program files\SDCC\source\TT_ACTION.C SDCC -c --no-xinit-opt --debug "C:\Program files\SDCC\source\TT_PROCS.C SDCC -c --no-xinit-opt --debug "C:\Program files\SDCC\source\TT_TABLES.C SDCC -c --no-xinit-opt --debug "C:\Program files\SDCC\source\TT_MAIN.C SDCC --debug --code-size 0x3A00 --xram-size 0x3C0 TT_MAIN.rel TT_INIT.rel TT_ACTION.rel TT_PROCS.rel TT_TABLES.rel cd "C:\Program files\SDCCGOTO END rem Usage : sdcc [options] filename rem Options :- rem -m Set the port to use e.g. - mz80. rem -p Select port specific processor e.g. -mpic14 -p16f84 rem ------<snip>------- REM Options available for ease of use as comments REM GAMEBOY REM -z Gameboy image as file[GB] REM List: REM -u Update listing file(s) with link data as file(s)[.RST] REM End: REM -e or null line terminates input :END ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=960614&group_id=599 |