|
|
View previous topic :: View next topic |
Author |
Message |
Willie Erasmus Guest
|
Shift_left, shift_right, rotate_left, rotate_right |
Posted: Wed Apr 02, 2003 3:31 am |
|
|
<font face="Courier New" size=-1>Hi
The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
Thanks
Willie
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13305 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: Shift_left, shift_right, rotate_left, rotate_right |
Posted: Wed Apr 02, 2003 8:53 am |
|
|
:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>
The shift functions works like a multiply or divide by 2. This requires you to specify the the size of the number you wish to perform this function on.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13309 |
|
|
Sherpa Doug Guest
|
Re: Shift_left, shift_right, rotate_left, rotate_right |
Posted: Wed Apr 02, 2003 9:54 am |
|
|
<font face="Courier New" size=-1>:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>
The functions all shift by one bit, "value" is a boolean. If you want it to shift a multi-byte word by one bit you must tell it how wide your word is. If you want to shift by several bits you call the function several times.
Does that help?
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13310 |
|
|
Willie Erasmus Guest
|
Re: Shift_left, shift_right, rotate_left, rotate_right |
Posted: Thu Apr 03, 2003 1:03 am |
|
|
Thanks for your replies
If I want to shift out 6 bits, would the function look like this: shift_left(PIN_B0,1,data) (data can be anything described by 6 bits). I now only put the shift function in a for-loop calling it 6 times?
Thanks
Willie
:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13339 |
|
|
Sherpa Doug Guest
|
Re: Shift_left, shift_right, rotate_left, rotate_right |
Posted: Thu Apr 03, 2003 7:52 am |
|
|
:=Thanks for your replies
:=
:=If I want to shift out 6 bits, would the function look like this: shift_left(PIN_B0,1,data) (data can be anything described by 6 bits). I now only put the shift function in a for-loop calling it 6 times?
:=
:=Thanks
:=Willie
:=
If you want to shift out a serial stream try something like:
for(i=0;i<6;i++){
output_bit(PIN_B0,shift_left(&data,1,0));
[wait for length of bit]
}
Which should shift out 6 bits from the byte "data" to pin B0. Note that the output bit of shift_left is its returned value. On the other end of the data 0's are shifted in.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13352 |
|
|
|
|
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
|