C-code error

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

User avatar
Jan Lichtenbelt
Posts: 794
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 261 times
Contact:

C-code error

Postby Jan Lichtenbelt » Sat Jan 19, 2013 11:23 am

What is wrong is this C-code (error message: missing right par , missing semicol.) at line FCV_ABD_FLAG= (baudcon,ABDEN)

while (!(FCV_ABD_FLAG == 0))
{

//Stop on overflow baud rate counting
//C Code:
if (baudcon,ABDOVF) // ABDOVF is overflow bit
{
FCV_COUNTH=FCV_COUNTH+1 // increase byte 3 with 1
}

FCV_ABD_FLAG= (baudcon,ABDEN); //save satus enable bit (will be auto cleared)


}


Kind regards

Jan Lichtenbelt

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 64 times
Been thanked: 306 times
Contact:

Re: C-code error

Postby JonnyW » Sat Jan 19, 2013 11:47 am

Though 'baudcon,ABDOVF' is technically C code, it probably wont be read OK by the BoostC compiler.

Did you mean: baudcon.ABDOVF (dot instead of comma)?

Also there is a missing semi-colon after:
FCV_COUNTH=FCV_COUNTH+1

Cheers,

Jonny

User avatar
Jan Lichtenbelt
Posts: 794
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 261 times
Contact:

Re: C-code error

Postby Jan Lichtenbelt » Sat Jan 19, 2013 2:29 pm

Hi Jonny,

Thanks for your help.

What I really want is a loop which wait until the ABDEN bit in the BAUDCON register gets 0 (disabled). Sometime like:

while (baudcon,ABDEN)
{
}

But is I put that in a C-box, it is show in the c file, but it never gets in the assembler version (.asm file)

What to do?

Kind regrads

Jan

Remark: BAUDCON Baud rate control register is described e.g. in the PIC16F1939 datasheet p. 302.

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 64 times
Been thanked: 306 times
Contact:

Re: C-code error

Postby JonnyW » Sat Jan 19, 2013 4:28 pm

Hi Jan.

If it is in the C code but not in the assembler it is probably being optimised out.

I haven't done much with the BoostC compiler, but the ',' (comma) operator is usually used in C to sequence operations.

This means that the code:
while (baudcon,ABDEN)
{
}

Will be reduced to:
while (ABDEN)
{
}

If this never makes the ASM, I'm guessing ABDEN is defined as bit 0, so this becomes:
while (0)
{
}

Which will be optimised out.

Try with a '.' (structure) operator instead and see if this works:
while (baudcon.ABDEN)
{
}

Cheers,

Jonny
These users thanked the author JonnyW for the post:
Jan Lichtenbelt (Sat Jan 19, 2013 4:43 pm)
Rating: 5.26%
 

User avatar
Jan Lichtenbelt
Posts: 794
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 261 times
Contact:

Re: C-code error

Postby Jan Lichtenbelt » Sat Jan 19, 2013 4:43 pm

Dear Jonny

It should indeed be a point instead of a comma:

while (baudcon.ABDEN)
{
}

The assembler file looks fine now!

Thanks a lot!

With kind regards

Jan Lichtenbelt