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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…