CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Bug: GLOBAL_INT assumes BSR=0

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Bug: GLOBAL_INT assumes BSR=0
PostPosted: Tue Sep 23, 2014 2:31 pm     Reply with quote

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: 19535

View user's profile Send private message

PostPosted: Thu Sep 25, 2014 1:18 am     Reply with quote

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).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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