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

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
 

AtomSoft

Well-Known Member
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:

xpi0t0s

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

Latest threads

EE World Online Articles

Loading
Top