Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[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
Joined
Jun 17, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
9
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(){

  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:

paulfjujo

Advanced Member level 4
Joined
Jun 9, 2008
Messages
1,390
Helped
280
Reputation
560
Reaction score
268
Trophy points
1,363
Location
France 01800
Activity points
9,719
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top