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.

problem in uart receiving (correction)

Status
Not open for further replies.

butters

Member
i have this code for uart receiving...
it is not working..
can somebody help me?
im trying to send bits from hyperterminal to usart... hence the uart is in receiving side...

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

char readUSART(void);


void main(void){


	// configure USART
  OpenUSART( USART_TX_INT_OFF  &
             USART_RX_INT_OFF  &
             USART_ASYNCH_MODE &
             USART_EIGHT_BIT   &
             USART_CONT_RX     &
             USART_BRGH_HIGH,25 );

 
firstCh = ReadUSART();
nextCh = ReadUSART();


 while (!DataRdyUSART()) /* busy wait*/;
firstCh = ReadUSART();
while (!DataRdyUSART()) /* busy wait*/;
nextCh = ReadUSART();
  



  //CloseUSART();

}
 
Try putting semi colons on the while lines,

Code:
    while (!DataRdyUSART())[COLOR="red"];[/COLOR]    /* busy wait*/;
    firstCh = ReadUSART();
    while (!DataRdyUSART())[COLOR="Red"];[/COLOR]    /* busy wait*/;
    nextCh = ReadUSART();

What you have at the moment is the equivalent of,

Code:
    while (!DataRdyUSART()){    /* busy wait*/;
        firstCh = ReadUSART();
    }
    while (!DataRdyUSART()){    /* busy wait*/;
        nextCh = ReadUSART();
    }

Mike.
 
i am able to build my programme but when i want to run it, theres an error...

ICD0083: Debug: Unable to enter debug mode. Please double click this message for more information.
 
That error is generated by the ICD2 not being able to enter debug mode. Click the error message to see the most common reason.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top