Page 1 of 1

C-code error

Posted: Sat Jan 19, 2013 11:23 am
by Jan Lichtenbelt
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

Re: C-code error

Posted: Sat Jan 19, 2013 11:47 am
by JonnyW
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

Re: C-code error

Posted: Sat Jan 19, 2013 2:29 pm
by Jan Lichtenbelt
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.

Re: C-code error

Posted: Sat Jan 19, 2013 4:28 pm
by JonnyW
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

Re: C-code error

Posted: Sat Jan 19, 2013 4:43 pm
by Jan Lichtenbelt
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