Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C18 Help

Status
Not open for further replies.

bryan

Member
Hello all:

Trying to port some code from sourceboost to C18. Why am I receiving a syntax error. Thanks in advance

Code:
void wait_for_zero_cross() 
{
if(X10_ZERO_CROSS) //c:17:Error: syntax error
{
while(X10_ZERO_CROSS);
}
else
{
while(!X10_ZERO_CROSS);
}
}
 
Thanks Mike. That appears to be the problem. It was defined as

#define X10_ZERO_CROSS portb.0

I changed it to #define X10_ZERO_CROSS LATBbits.LATB0

and it compiled until the next error <g>

Oh well getting there.!!

-=Bryan=-
 
Last edited:
And therein lies your problem, in C18 you access bits by using SFRnamebits.bitname and so your define should be,

#define X10_ZERO_CROSS PORTBbits.RB0;

You will also find that C18 requires all SFR names in upper case.

Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top