View previous topic :: View next topic |
Author |
Message |
Benjamin
Joined: 11 Jan 2006 Posts: 21 Location: Quebec (Canada)
|
Using bits on 16bit microcontroller |
Posted: Mon Dec 13, 2010 1:32 pm |
|
|
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
|
|
Posted: Mon Dec 13, 2010 1:46 pm |
|
|
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
|
|
Posted: Mon Dec 13, 2010 1:56 pm |
|
|
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)
|
|
Posted: Mon Dec 13, 2010 2:16 pm |
|
|
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! |
|
|
|