Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 4th June 2009, 07:50 AM   #1
Default problem in uart receiving (correction)

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();

}
butters is offline  
Old 4th June 2009, 07:57 AM   #2
Default

Try putting semi colons on the while lines,

Code:
    while (!DataRdyUSART());    /* busy wait*/;
    firstCh = ReadUSART();
    while (!DataRdyUSART());    /* 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.
Pommie is offline  
Old 4th June 2009, 08:45 AM   #3
Default

is the closeusart(); necessary?
butters is offline  
Old 4th June 2009, 10:02 AM   #4
Default

Quote:
Originally Posted by butters View Post
is the closeusart(); necessary?
I doubt it.

Mike.
Pommie is offline  
Old 4th June 2009, 10:10 AM   #5
Default

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.
butters is offline  
Old 4th June 2009, 10:37 AM   #6
Default

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.
Pommie is offline  
Reply

Tags
correction, problem, receiving, uart

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
USART/UART data receiving problem mbarren Micro Controllers 32 28th May 2009 01:24 AM
UART Transmitting Problem winson Micro Controllers 9 20th January 2009 03:01 AM
USART Receiving a String Problem Suraj143 Micro Controllers 13 17th June 2008 07:53 AM
PIC16F628A USART receiving problem AWHF Micro Controllers 12 15th March 2008 05:26 PM
Real time freq correction problem Rosco101 Electronic Projects Design/Ideas/Reviews 2 8th April 2005 12:02 PM



All times are GMT. The time now is 10:20 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker