Continue to Site

[PIC]Hi, I'm using the sofware UART lib.. but the problem is that if there is no characat

Status
Not open for further replies.

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

Code:
char i, error, byte_read;                 // Auxiliary variables

void main(){

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
PORTC=~PORTC;
}
}

Last edited by a moderator:

paulfjujo

Advanced Member level 4
hello

Code:
 error = Soft_UART_Init(&PORTC, 7, 6, 9600, 0); // Initialize Soft UART at 14400 bps
.......
........
PORTC=~PORTC;

You can not modify PORTC like this, because use of UART !!!
you can modify only unsued bits of PORTC..

Wich MCU used ?
What is your C language ?

Status
Not open for further replies.