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 support@ccsinfo.com

#byte access of FSR0H / FSR0L

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



Joined: 29 Sep 2006
Posts: 118

View user's profile Send private message

#byte access of FSR0H / FSR0L
PostPosted: Fri Oct 23, 2009 8:07 am     Reply with quote

Hi,

Does any body know why the compiler clears FSR0H when loading FSR0L ? First I though it might be a odd/even adress thing but if I do the same loading on for example ADCON1/2 then it does it OK...

Code:

#byte  FSR0H   = 0xFEA
#byte  FSR0L   = 0xFE9
#byte ADCON1   = 0xfc1
#byte ADCON2   = 0xfc0

....................   
....................   FSR0H = 0x11;
00212:  MOVLW  11
00214:  MOVWF  FEA
....................   FSR0L = 0x22;
00216:  CLRF   FEA                       <<< OUCH! WHY????
00218:  MOVLW  22
0021A:  MOVWF  FE9
....................   
....................   AdCON2 = 0x55;
0021C:  MOVLW  55
0021E:  MOVWF  FC0
....................   ADCON1 = 0x44;
00220:  MOVLW  44
00222:  MOVWF  FC1
....................   


regards,
Edwin.
Compiler version PCWHD 4.099
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 23, 2009 2:12 pm     Reply with quote

The quick solution is just to change the order of the lines.
Torello



Joined: 29 Sep 2006
Posts: 118

View user's profile Send private message

PostPosted: Fri Oct 23, 2009 4:03 pm     Reply with quote

I though of that solution too. But knowing -why- it is done give me more confidence that this solution stays working in the future....

A support request on this issue has been submitted to CCS.

(any thoughts are of course still welcome)
Ttelmah
Guest







PostPosted: Sat Oct 24, 2009 2:56 am     Reply with quote

I think you will find the reason is that the compiler already has a _16bit_ variable, called 'FSR0L' defined.

The #byte directive works in two different ways. If no variable exists with the name being used, it created an 8bit variable, and maps it to the defined address. If a variable already exists with the name, it maps this variable to the address.
So the compiler already has a 16bit variable called FSR0L defined, and when it sees the #byte directive, maps _this_ to the address. Hence when you access FSR0L, it accesses both addresses. Two solutions:

1) Use your own name to avoid any possible clash with the compiler 'My_FSR0L' for example.

2) Assume that the compiler's FSR0L, does not 'mind' being at the FSR address, and use:
Code:


#byte  FSR0L   = 0xFE9

   FSR0L = 0x1122;


Best Wishes
Torello



Joined: 29 Sep 2006
Posts: 118

View user's profile Send private message

PostPosted: Tue Oct 27, 2009 9:27 am     Reply with quote

Were is this _16bit_ applied on the definitions of Fsr's?

Solution 1 does -not- work:
Code:

....................   
....................   My_fsr0H = make8(Dbf,1);
00342:  MOVFF  213,FEA
....................   My_fsr0L = make8(Dbf,0);
00346:  MOVF   x12,W
00348:  CLRF   FEA
0034A:  MOVWF  FE9
....................   


Solution 2 to be used Very Happy

Thanks,
Edwin
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