View previous topic :: View next topic |
Author |
Message |
GiGi Guest
|
Expecting a close paren |
Posted: Mon Jan 25, 2010 5:29 pm |
|
|
Code: | void Write_Register (unsigned char RegAddress, unsigned char DLength)
{
unsigned char ByteCounter,
BitMask,
*PtrHighByte;
/*---------------------------------------------------------------------------------*/
/* Preparing to send the data */
/* Calculate the position of the MSB to send */
/* Beginning the register read or write cycle */
BitMask = 0x000001;
ByteCounter = 0;
if (DLength != 0)
{
while (--DLength)
if ( (BitMask <<= 1) == 0)
{
BitMask = 0x000001;
ByteCounter++;
}
}
*PtrHighByte = ((unsigned char*)input(DIN))+ByteCounter;
/* It's a register Write cycle */
/*---------------------------------------------------------------------------------*/
/* Sending the new register value */
/* Note : DLength is now used to signal the end of the emission */
delay_ms(10);
/* Start sending the DLength data bits to the 01 register */
write_bit((*PtrHighByte & BitMask) != 0); /* Send the Bit Value */ {
if ( (BitMask >>= 1) == 0)
{ /* Prepare to test next bit */
BitMask = 0x800000;
PtrHighByte--;
if ((ByteCounter--) == 0)
DLength = 1;
}
}
while (DLength != 1); /* Have all the data bits been sent ? */
}
/* Return from subroutine */ |
Hi, I have a problem with 'Expecting a close paren' in 'write_bit((*PtrHighByte & BitMask) != 0); ' I couldn't find out where the error is. I want to call the function 'write-bit' I wrote. Could you help me with this? Thank you very much! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 25, 2010 5:38 pm |
|
|
My advice is to get rid of all the * comments (delete them all)
and clean up the formatting on the code. Then you should be
able to easily spot the problems. |
|
|
Guest
|
|
Posted: Mon Jan 25, 2010 9:01 pm |
|
|
PCM programmer wrote: | My advice is to get rid of all the * comments (delete them all)
and clean up the formatting on the code. Then you should be
able to easily spot the problems. |
why is that? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Mon Jan 25, 2010 9:06 pm |
|
|
Because the /*comments*/ are making it hard to see the cause of the error.
I can see it but he was wanting you to see it for yourself.
It was because of this type of problem I started to avoid using /* a long time ago
and started using // for comments _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 26, 2010 3:29 am |
|
|
It is a question slightly of what you are doing 'with' the comments.
Reserve /*, and */, for 'block comments' before the start, or after the end of the code, using multiple lines. For 'in line' comments, use //. This is especially worthwhile, if you are using pointers in a code block.
Good formatting, and use of comments, helps to simplify seeing errors, and reading the code. In line use of /* */, doesn't help this, and add a bit of strange formatting, and everything becomes much harder...
In this case, just count the brackets on each code line.
Remember that errors like this, often actually reflect an error earlier in the code.
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Jan 26, 2010 10:48 am |
|
|
There are also editors to help you match braces and paren's.
What editor are you using to work on your code?
I like UltraEdit32, MPLAB and vi (Unix).
-ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
GiGI Guest
|
|
Posted: Tue Jan 26, 2010 12:19 pm |
|
|
Thank you guys.
With your help, I found the error which exists in the function of 'write_bit'. |
|
|
|