Mikroc, Soft_uart_read, Soft_uart_write – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 270

Advertising
background image

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

262

MikroElektronika: Development tools - Books - Compilers

page

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_Read

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

Soft_Uart_Write

Advertising
This manual is related to the following products: