medocntrl
Newbie level 2

Hi,
I'm using the sofware UART lib.. but the problem is that if there is no characatere to be received, it still waiting in the function...
I'm using the sofware UART lib.. but the problem is that if there is no characatere to be received, it still waiting in the function...
Code:
char i, error, byte_read; // Auxiliary variables
void main(){
ADCON1=7;
TRISB = 0x00; // Set PORTB as output (error signalization)
PORTB = 0; // No error
TRISC=0;
PORTC=0;
error = Soft_UART_Init(&PORTC, 7, 6, 9600, 0); // Initialize Soft UART at 14400 bps
Soft_UART_Write('s');
while(1) { // Endless loop
byte_read = Soft_UART_Read(&error); // Read byte, then test error flag waiting in thise function
Soft_UART_Write(byte_read); // If error was not detected, return byte read
if(byte_read=='0')PORTB = 0;
if(byte_read=='1')PORTB = 1;
if(byte_read=='2')PORTB = 2;
PORTC=~PORTC;
}
}
Last edited by a moderator: