|
|
View previous topic :: View next topic |
Author |
Message |
Kasper
Joined: 14 Jan 2004 Posts: 88 Location: Aurora, Ontario, Canada
|
shift_right help please |
Posted: Tue Jan 20, 2004 1:45 pm |
|
|
Hi.
in trying to implement the below code, the compiler keeps giving me an error:
*** Error 28 "..." Line 86(32,45): Expecting an identifier
looking at the manual, I cannot really tell what I am doing wrong here :(
Any help would be appreciated
Compiler: 3.184, WinXP, 16F877, ICD2
This is what it says in the manual:
Quote: |
// This shifts 8 bits out PIN_A0, LSB first.
for(i=0;i<8;++i)
output_bit(PIN_A0,shift_right(&data,1,0));
|
Code: |
#define ReceiveBufferSize 25
char ReceiveBuffer[ReceiveBufferSize];
main() {
for(i=0;i<(8*ReceiveBuffer);i++) {
output_bit(pin_a0,shift_right(&ReceiveBuffer,1,0));
output_high(S2);
delay_us(TCLKH);
output_low(S2);
delay_us(TCLKL);
}// end of for.
}// end main
| [/quote] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 20, 2004 5:40 pm |
|
|
The problem is in this line:
Quote: | output_bit(pin_a0,shift_right(&ReceiveBuffer,1,0)); |
ReceiveBuffer is an array, and in C, the name of the array, used by
itself, is the address of the 1st element. You don't need the & symbol.
That's why the compiler is complaining.
Another way to get the address of the 1st element is this:
&ReceiveBuffer[0]
I do have one question. Your ReceiveBuffer array has 25 elements,
but you have set the middle number in the shift_right() function = 1.
This will cause it to only shift the first array element. Based on
the rest of your code, I think you really want to set it = 25.
ie., the corrected line should look like this:
output_bit(PIN_A0, shift_right(ReceiveBuffer, RECEIVE_BUFFER_SIZE,0)); |
|
|
|
|
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
|