![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
tipoldo
Joined: 01 Feb 2006 Posts: 14 Location: Palma Mallorca
|
wrong dispatcher code |
Posted: Wed Feb 27, 2008 10:21 am |
|
|
Hi,
I'm using the CCS PCM C Compiler Version 3.236 on a PIC 16F690. I have to use the comp2_isr in my code to implement a project. I get crazy because sometimes the program had really strange behaviour. Analyzing and tracing the assembler code, I found that the compiler doesn't restore the W register well on interrupt return. Here is the interrupt dispatcher code that the CCS generates in my code:
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 26
0008: MOVF 7F,W
0009: MOVWF 25
000A: MOVF 0A,W
000B: MOVWF 2D
000C: CLRF 0A
000D: SWAPF 25,F
000E: MOVF 04,W
000F: MOVWF 27
0010: MOVF 20,W
0011: MOVWF 28
0012: MOVF 21,W
0013: MOVWF 29
0014: MOVF 22,W
0015: MOVWF 2A
0016: MOVF 23,W
0017: MOVWF 2B
0018: MOVF 24,W
0019: MOVWF 2C
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8D
001D: MOVWF 04
001E: BTFSS 00.6
001F: GOTO 022
0020: BTFSC 0D.6
0021: GOTO 035
0022: MOVF 27,W
0023: MOVWF 04
0024: MOVF 28,W
0025: MOVWF 20
0026: MOVF 29,W
0027: MOVWF 21
0028: MOVF 2A,W
0029: MOVWF 22
002A: MOVF 2B,W
002B: MOVWF 23
002C: MOVF 2C,W
002D: MOVWF 24
002E: MOVF 2D,W
002F: MOVWF 0A
0030: SWAPF 26,W
0031: MOVWF 03
0032: SWAPF 7F,F
0033: SWAPF 7F,W
0034: RETFIE
Highlighted in red is the code where the compiler save the W register, watching it, it saves the W register in the 0x25 register and swaps it. To do it, the compiler use a temporal register (0x7F). But when the compiler wanted to restore the W register, it is restored with the value of the 0x7F register (highlighted in blue color) instead of the 0x25 register. Unfortunately the compiler uses the temporal 0x7F register into my interrupt function as a register for temporal variable, and therefore the code doesn't restore right the W register when I come back from the interrupt function.
To continue with my project, as a workaround, I have written the following assembler code at the end of the interrupt function comp2_isr():
#ASM
SWAPF 0x25,W
MOVWF 0x7F
#ENDASM
But I don't like it. How can I resolve it? |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Feb 27, 2008 10:29 am |
|
|
What compiler version are you using, and have you informed CCS about this? They don't always monitor this BBS. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
tipoldo
Joined: 01 Feb 2006 Posts: 14 Location: Palma Mallorca
|
|
Posted: Wed Feb 27, 2008 10:39 am |
|
|
I'm using the PCM Version 3.236, and I haven't informed about this to CCS yet. Where should I do that? |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Feb 27, 2008 12:25 pm |
|
|
At the top of this page near the CCS logo is a link to "Official CCS Support"
Then at the right under Quick Links they tell you how to get official support. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|