Mikroelektronika MIKROE-350 Datenbogen
Soft_UART_Read
353
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function Soft_UART_Read(dim byref error as byte) as byte
Returns
Byte received via UART.
Description
The function receives a byte via software UART.
This is a blocking function call (waits for start bit). Programmer can unblock it by
calling Soft_UART_Break routine.
calling Soft_UART_Break routine.
Parameters :
-
error:
Error flag. Error code is returned through this variable.
-
0
- no error
-
1
- stop bit error
-
255
- user abort, Soft_UART_Break called
Requires
Software UART must be initialized before using this function. See the
Soft_UART_Init routine.
Soft_UART_Init routine.
Example
dim data as byte
error
as byte
...
' wait until data is received
do
' wait until data is received
do
data = Soft_Uart_Read(error)
loop until (error = 0)
' Now we can work with data:
if (data) then
...
end if
if (data) then
...
end if