mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

Soft_Uart_Read

Prototype

unsigned short Soft_Uart_Read(unsigned short *error);

 

 

Returns

Returns a received byte.

 

 

Description

Function receives a byte via software UART. Parameter error will be zero if the

 

transfer was successful. This is a non-blocking function call, so you should test the

 

error manually (check the example below).

 

 

Requires

Soft UART must be initialized and communication established before using this func-

 

tion. See Soft_Uart_Init.

 

 

Example

// Here’s a loop which holds until data is received:

 

do

 

data = Soft_Uart_Read(&error);

 

while (error);

 

// Now we can work with it:

 

if (data) {...}

 

 

Soft_Uart_Write

Prototype

void Soft_Uart_Write(char data);

 

 

Description

Function transmits a byte (data) via UART.

 

 

Requires

Soft UART must be initialized and communication established before using this func-

 

tion. See Soft_Uart_Init.

 

Be aware that during transmission, software UART is incapable of receiving data – data

 

transfer protocol must be set in such a way to prevent loss of information.

 

 

Example

char some_byte = 0x0A;

 

...

 

Soft_Uart_Write(some_byte);

 

 

page

 

262

MikroElektronika: Development tools - Books - Compilers