|
|
View previous topic :: View next topic |
Author |
Message |
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Bug: GLOBAL_INT assumes BSR=0 |
Posted: Tue Sep 23, 2014 2:31 pm |
|
|
Code: | #device PIC16F1823
. . .
#INT_GLOBAL
void isr()
{
if(PIR1.RCIF) //..RCREG1 is full. RCIF will be cleared when RCREG is read
{
isrChar = RCREG; //..this clears RCIF
. . . |
Using PCM version 4.128, Release target, any level of optimization, this compiles to:
Code: | .................... #INT_GLOBAL
.................... void isr()
.................... {
.................... if(PIR1.RCIF) //..RCREG1 is full. RCIF will be cleared when RCREG is read
*
0004: BTFSS 11.5
0005: GOTO 058
.................... {
.................... isrChar = RCREG; //..this clears RCIF
0006: MOVLB 03
0007: MOVF 19,W
0008: MOVLB 00
0009: MOVWF 5E |
which is wrong because the instruction at 0004 is based on whatever the BSR was at the time of the interrupt. My work-around is:
Code: | #INT_GLOBAL
void isr()
{
#asm
MOVLB 0
#endasm
. . .
|
_________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Sep 25, 2014 1:18 am |
|
|
Report it to CCS.
The 'reason', is because of the chip.
Historically, the global handler on a PIC16, must always start with basic code to save the W register, SFR, and BSR. Hence the bank would be set to access the locations used to store these.
Your chip is one of the later PIC16's, that automatically saves these registers. You have therefore written a handler that doesn't do these saves. Because the CCS code pre-dates these chips, it isn't smart enough to realise that this might happen, and assumes the bank will have been set at the start of the global handler......
Though your's is a very old compiler, the same behaviour was still present on later V4 compilers (haven't checked with V5). |
|
|
|
|
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
|