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

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

C-code error

Post 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

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

Re: C-code error

Post 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

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

Re: C-code error

Post 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.

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

Re: C-code error

Post 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

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

Re: C-code error

Post 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

Post Reply