Component: UART Software (Timer) (Comms: Interface)

From Flowcode Help
Jump to navigationJump to search


Author MatrixTSL
Version 1.0 (Release)
Category Comms: Interface


Image UART Software (Timer) component

Creates a reliable software UART that can be driven using a timer interrupt setup by the user. The timer interrupt must be interrupting at the required baud rate. e.g 9600Hz.

Examples

Simple example showing how to enable a timer interrupt at the desired baud rate then receive a string. If anything is received then it will be echoed back out and displayed on a LCD

FC6 Icon.png UART_Timer_Example


Downloadable macro reference

SendString

Sends an string to the transmit buffer

Parameters

<- STRING Data
This parameter may be returned back to the caller


Return value

This call does not return a value


ReceiveArray

Gets an array of values from the receive buffer.

Returns number of values received.

Parameters

UINT Values
UINT NumValues
UINT Timeout
Time in milliseconds to wait for data


Return value

UINT


SendArray

Sends an array of values to the transmit buffer

Parameters

UINT Values
UINT NumValues


Return value

This call does not return a value


UART_Timer_Process

Called as part of a timer interrupt at the specific UART baud rate.

Parameters

This macro has no parameters


Return value

This call does not return a value


ReceiveValue

Gets a single value from the receive buffer

Parameters

UINT Timeout
Time in milliseconds to wait for data


Return value

UINT


SendValue

Sends a single value to the transmit buffer

Parameters

UINT Value


Return value

This call does not return a value


CheckBuffer

Returns the number of values in the transmit or receive buffer

Parameters

BOOL Buffer
0=Transmit / 1=Receive


Return value

UINT


ReceiveString

Gets a string from the receive buffer

Parameters

UINT MaxChars
UINT Timeout
Time in milliseconds to wait for data


Return value

STRING


Initialise

Initialises the UART component pins ready to send and receive data

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Data Bits

This property is of type Fixed list of ints and can be referenced with the variable name DataBits.

Sets the number of data bits in a single packet, 7-bits provides values 0-127, 8-bits provides values 0-255 and 9-bits provides values 0-511.

9-bit data is often used for 8-bit plus a parity bit which is used for error detection.

Stop Bits

This property is of type Fixed list of ints and can be referenced with the variable name StopBits.

Number of stop bits at the end of each packet. Used to adjust the minimum spacing between packets.

Use TX

This property is of type True or false and can be referenced with the variable name UseTx.

Allows the Transmit pin to be enabled / disabled

Use RX

This property is of type True or false and can be referenced with the variable name UseRx.

Allows the Receive pin to be enabled / disabled

Transmit Pin

This property is of type Single digital pin and can be referenced with the variable name TXPin.

Pin assigned to transmitting data

Transmit Buffer Size

This property is of type Unsigned integer and can be referenced with the variable name TXBufferSize.

Number of bytes that can be stored in the outgoing transmit buffer

Receive Pin

This property is of type Single digital pin and can be referenced with the variable name RXPin.

Pin assigned to receiving data

Receive Buffer Size

This property is of type Unsigned integer and can be referenced with the variable name RXBufferSize.

Number of bytes that can be stored in the incoming receive buffer

Injector

This property is of type Fixed list of ints and can be referenced with the variable name Injector.

Points to an Injector component on the panel to provide a means to connect the simulation data to something useful such as another instance of Flowcode or real world hardware.