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

64-bit output

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







64-bit output
PostPosted: Thu May 09, 2002 3:43 pm     Reply with quote

Hello All,

I am trying to output 64-bits of data serially at a 2kHz rate through a single output pin. I am using the shift_left command to do this. My partial code is:

byte chan0[8] = {0xF6, 0xDB, 0x6D, 0xB7,
0xBD, 0xB7, 0xBD, 0xEF};

//// *** output here **** /////
for (n=0; n<8; n++)
{
for (m=0; m<8; m++)
{
// output MSB of byte[n]; 1-byte only; replace w/ 0
signal_temp = chan0[n];
output_bit(PIN_B0, shift_left(signal_temp, 1, 0));
delay_us(500); //sets 2kHz rate
}
}

I am not seeing anything out of PIN_B0. Through troubleshooting, I know that the routine is being called and that the for-loop is running correctly. I think that the problem is with the shift_left command (I used an example from the CCS help files, but don't have any other documentation on how this works).

Does anyone see anything wrong w/ my code? Or does anyone know a better way to output a 64-bit signal serially at a 2kHz (the order needs to be MSB -> LSB)?

Thanks in advance for anyone w/ input!
___________________________
This message was ported from CCS's old forum
Original Post ID: 4265
Todd C. Micallef
Guest







Re: 64-bit output
PostPosted: Thu May 09, 2002 7:07 pm     Reply with quote

<font face="Courier New" size=-1>First, since you didn't list the entire program it's hard to determine the port b problem. My guess would be that you don't have the port b pull-ups enabled(if the chip supports them).
The function PORT_B_PULLUPS(TRUE); should help if this is the reason you don't see the value change.

Second look at the file "ex_sqw.c" for an example on sending data at a specific rate.


Try making these other changes...

No guarantees this is 100\% correct, but should get you in the ballpark.

:=Hello All,
:=
:=I am trying to output 64-bits of data serially at a 2kHz rate through a single output pin. I am using the shift_left command to do this. My partial code is:

byte chan0[8] = {0xF6, 0xDB, 0x6D, 0xB7,
0xBD, 0xB7, 0xBD, 0xEF};

//// *** output here **** /////
for(n=0;n<64;n++)
{
// output MSB of byte[n]; 1-byte only; replace w/ 0
output_bit(PIN_B0, shift_left(chan0, 8, 0));//8=8bytes
delay_us(250); //sets 2kHz rate
output_bit(PIN_B0,0); //If bit was high, goes to low: 50\%duty
delay_us(250);
}

:=I am not seeing anything out of PIN_B0. Through troubleshooting, I know that the routine is being called and that the for-loop is running correctly. I think that the problem is with the shift_left command (I used an example from the CCS help files, but don't have any other documentation on how this works).
:=
:=Does anyone see anything wrong w/ my code? Or does anyone know a better way to output a 64-bit signal serially at a 2kHz (the order needs to be MSB -> LSB)?
:=
:=Thanks in advance for anyone w/ input!</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 4269
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: 64-bit output
PostPosted: Thu May 09, 2002 10:58 pm     Reply with quote

The shift left command is used to shift bits into an array. I do not think it returns the value shifted out. If it did, I see a problem in your logic. Each time through the m for loop the signal_temp gets reassigned. It should have been outside the m loop. If I were doing this, I would do something like the following:

byte chan0[8] = {0xF6, 0xDB, 0x6D, 0xB7,
0xBD, 0xB7, 0xBD, 0xEF};

//// *** output here **** /////
for (n=0; n<8; n++)
{
signal_temp = chan0[n];
for (m=0; m<8; m++)
{
// output MSB of byte[n]
if (signal_temp & 0x80)
output_high(PIN_B0);
else
output_low(PIN_B0);
signal_temp <<= 1;
delay_us(500); //sets 2kHz rate
}
}

Depending on what you are doing, you could also use a timer int to avoid wasting CPU time.

Mark

:=Hello All,
:=
:=I am trying to output 64-bits of data serially at a 2kHz rate through a single output pin. I am using the shift_left command to do this. My partial code is:
:=
:=byte chan0[8] = {0xF6, 0xDB, 0x6D, 0xB7,
:= 0xBD, 0xB7, 0xBD, 0xEF};
:=
:=//// *** output here **** /////
:=for (n=0; n<8; n++)
:={
:= for (m=0; m<8; m++)
:= {
:= // output MSB of byte[n]; 1-byte only; replace w/ 0
:= signal_temp = chan0[n];
:= output_bit(PIN_B0, shift_left(signal_temp, 1, 0));
:= delay_us(500); //sets 2kHz rate
:= }
:=}
:=
:=I am not seeing anything out of PIN_B0. Through troubleshooting, I know that the routine is being called and that the for-loop is running correctly. I think that the problem is with the shift_left command (I used an example from the CCS help files, but don't have any other documentation on how this works).
:=
:=Does anyone see anything wrong w/ my code? Or does anyone know a better way to output a 64-bit signal serially at a 2kHz (the order needs to be MSB -> LSB)?
:=
:=Thanks in advance for anyone w/ input!
___________________________
This message was ported from CCS's old forum
Original Post ID: 4273
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