syntax error

Status
Not open for further replies.

butters

Member
hi all.. can i know why is there syntax error at the main end.
please take a look at my code and help me in rectifying the problem..
thanks!



Code:
#include <p18C452.h>
#include <usart.h>


void main(){

char rx1='k';

 // configure USART

  OpenUSART( USART_TX_INT_OFF  &

             USART_RX_INT_OFF  &

             USART_ASYNCH_MODE &

             USART_EIGHT_BIT   &

             USART_CONT_RX     &

             USART_BRGH_HIGH,25 );



while (1)
     {

if (DataRdyUSART())
       {
           if(RCSTAbits.OERR)
           {
           RCSTAbits.CREN=0;
           Nop();
           RCSTAbits.CREN=1;
           printf("\n\r OERR");
   
        }
       
        if(RCSTAbits.FERR){
           printf("\n\r FERR");
           while(!DataRdyUSART()){     
           printf("\n\r FERRin");
           rx1=RCREG;
         }
     }
        rx1=RCREG;
        printf("\n\rkey detected:");
        while(!BusyUSART());
        WriteUSART(rx1); //writing a byte to the USART



}


}    //main end <<<<<<<<<the syntax error
 
Code:
#include <p18C452.h>
#include <usart.h>


void main(){

char rx1='k';

 // configure USART

  OpenUSART( USART_TX_INT_OFF  &

             USART_RX_INT_OFF  &

             USART_ASYNCH_MODE &

             USART_EIGHT_BIT   &

             USART_CONT_RX     &

             USART_BRGH_HIGH,25 );



while (1){

    if (DataRdyUSART()){
        if(RCSTAbits.OERR){
            RCSTAbits.CREN=0;
            Nop();
            RCSTAbits.CREN=1;
            printf("\n\r OERR");
        }
       
        if(RCSTAbits.FERR){
            printf("\n\r FERR");
            while(!DataRdyUSART()){     
    	        printf("\n\r FERRin");
    	        rx1=RCREG;
            }
        }
        
        rx1=RCREG;
        printf("\n\rkey detected:");
        while(!BusyUSART());
        WriteUSART(rx1); //writing a byte to the USART

    }
}    //main end <<<<<<<<<the syntax error
}

add a extra }
 
Last edited:
You've just discovered the point of code formatting. Is the error any easier to spot in this layout:
Code:
#include <p18C452.h>
#include <usart.h>

void main()
{
	char rx1='k';
	// configure USART
	OpenUSART( USART_TX_INT_OFF  &
	USART_RX_INT_OFF  &
	USART_ASYNCH_MODE &
	USART_EIGHT_BIT   &
	USART_CONT_RX     &
	USART_BRGH_HIGH,25 );

	while (1)
	{
		if (DataRdyUSART())
		{
			if(RCSTAbits.OERR)
			{
				RCSTAbits.CREN=0;
				Nop();
				RCSTAbits.CREN=1;
				printf("\n\r OERR");
			}
			if(RCSTAbits.FERR)
			{
				printf("\n\r FERR");
				while(!DataRdyUSART())
				{     
					printf("\n\r FERRin");
					rx1=RCREG;
				}
			}
			rx1=RCREG;
			printf("\n\rkey detected:");
			while(!BusyUSART());
			WriteUSART(rx1); //writing a byte to the USART
		}
	}    //main end <<<<<<<<<the syntax error
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…