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

Using bits on 16bit microcontroller

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



Joined: 11 Jan 2006
Posts: 21
Location: Quebec (Canada)

View user's profile Send private message Visit poster's website

Using bits on 16bit microcontroller
PostPosted: Mon Dec 13, 2010 1:32 pm     Reply with quote

Hello,

I'm new with 16 bit microcontrollers, and using DSPIC33FJ256GP710. I've changed my register addressing to "#word" instead of "#byte", but when I set a bit in a register, CCS sets it as if it was a byte?

For example:
Code:

...
#word U2TXREG   =   0x234
#bit  TX9D  = U1TXREG.8
...
TX9D2 = 0;
...


will give in assembler:

Code:

.................... TX9D2 = 0;
01ABE:  BCLR.B  235.0


I expected:
Code:

01ABE:  BCLR.B  234.8


This may be OK, but I just want to verify that it is not a bug. I couldn't find in the datasheet if we could address registers this way. Or am I doing something wrong?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Dec 13, 2010 1:46 pm     Reply with quote

It's a correct 16 Bit PIC instruction. BCLR.B 234.8 doesn't exist, BCLR 234.8 would be correct, too.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 13, 2010 1:56 pm     Reply with quote

BCLR.B means Bit clear.byte mode according to Table 23.1 of the PIC data sheet.
Bytes only have 8 bits(0...7)

now if the instruction had been

BCLR.W ...that's ,word mode, and 8 would be the correct bit.

at least it does compile correctly !
Benjamin



Joined: 11 Jan 2006
Posts: 21
Location: Quebec (Canada)

View user's profile Send private message Visit poster's website

PostPosted: Mon Dec 13, 2010 2:16 pm     Reply with quote

Very logic. Thanks for the fast answers for a not so bright question (.B = Byte). I wasn't sure that we could access the registers by byte.

Thanks again!
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