Difference between revisions of "Component: UART Software (Timer) (Comms: Interface)"

From Flowcode Help
Jump to navigationJump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| MatrixTSL
 
| MatrixTSL
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 1.0 (Release)
+
| 1.0
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| Comms: Interface
 
| Comms: Interface
 
|}
 
|}
  
  
 +
==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.
  
==[[File:Component Icon 743ea495_34e7_47ee_bd79_3bfdc067b01c.png|Image]] UART Software (Timer) component==
+
==Component Pack==
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==
+
COMMSC
  
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
+
==Detailed description==
  
{{Fcfile|UART_Timer_Example.fcfx|UART_Timer_Example}}
 
  
  
==Downloadable macro reference==
 
  
===<span style="font-weight: normal;"><u><tt>SendString</tt></u></span>===
 
Sends an string to the transmit buffer
 
  
'''Parameters'''
 
  
:[[Variable Types|<- STRING]] ''Data''
 
::''This parameter may be returned back to the caller''
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>ReceiveArray</tt></u></span>===
+
''No detailed description exists yet for this component''
Gets an array of values from the receive buffer.
 
  
Returns number of values received.
+
==Examples==
  
'''Parameters'''
 
  
:[[Variable Types|UINT]] ''Values''
 
  
:[[Variable Types|UINT]] ''NumValues''
 
  
:[[Variable Types|UINT]] ''Timeout''
 
::Time in milliseconds to wait for data
 
  
  
'''Return value'''
 
  
:[[Variable Types|UINT]]
 
  
  
===<span style="font-weight: normal;"><u><tt>SendArray</tt></u></span>===
 
Sends an array of values to the transmit buffer
 
  
'''Parameters'''
 
  
:[[Variable Types|UINT]] ''Values''
 
  
:[[Variable Types|UINT]] ''NumValues''
 
  
 +
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
  
'''Return value'''
+
{{Fcfile|UART_Timer_Example.fcfx|UART_Timer_Example}}
  
:''This call does not return a value''
 
  
 +
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>UART_Timer_Process</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Called as part of a timer interrupt at the specific UART baud rate.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendString'''
 +
|-
 +
| colspan="2" | Sends an string to the transmit buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveArray'''
 +
|-
 +
| colspan="2" | Gets an array of values from the receive buffer. Returns number of values received.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Values
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | NumValues
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Timeout
 +
|-
 +
| colspan="2" | Time in milliseconds to wait for data&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendArray'''
 +
|-
 +
| colspan="2" | Sends an array of values to the transmit buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Values
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | NumValues
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:''This call does not return a value''
 
  
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UART_Timer_Process'''
 +
|-
 +
| colspan="2" | Called as part of a timer interrupt at the specific UART baud rate.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>ReceiveValue</tt></u></span>===
 
Gets a single value from the receive buffer
 
  
'''Parameters'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveValue'''
 +
|-
 +
| colspan="2" | Gets a single value from the receive buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Timeout
 +
|-
 +
| colspan="2" | Time in milliseconds to wait for data&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|UINT]] ''Timeout''
 
::Time in milliseconds to wait for data
 
  
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendValue'''
 +
|-
 +
| colspan="2" | Sends a single value to the transmit buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Value
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Return value'''
 
  
:[[Variable Types|UINT]]
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckBuffer'''
 +
|-
 +
| colspan="2" | Returns the number of values in the transmit or receive buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | 0=Transmit / 1=Receive&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>SendValue</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Sends a single value to the transmit buffer
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString'''
 +
|-
 +
| colspan="2" | Gets a string from the receive buffer&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | MaxChars
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Timeout
 +
|-
 +
| colspan="2" | Time in milliseconds to wait for data&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|UINT]] ''Value''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Initialises the UART component pins ready to send and receive data&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>CheckBuffer</tt></u></span>===
 
Returns the number of values in the transmit or receive buffer
 
 
'''Parameters'''
 
 
:[[Variable Types|BOOL]] ''Buffer''
 
::0=Transmit / 1=Receive
 
 
 
'''Return value'''
 
 
:[[Variable Types|UINT]]
 
 
 
===<span style="font-weight: normal;"><u><tt>ReceiveString</tt></u></span>===
 
Gets a string from the receive buffer
 
 
'''Parameters'''
 
 
:[[Variable Types|UINT]] ''MaxChars''
 
 
:[[Variable Types|UINT]] ''Timeout''
 
::Time in milliseconds to wait for data
 
 
 
'''Return value'''
 
 
:[[Variable Types|STRING]]
 
 
 
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
 
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==
 
==Property reference==
<span style="font-weight: normal;"><u>Data Bits</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''DataBits''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
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.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
9-bit data is often used for 8-bit plus a parity bit which is used for error detection.
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Stop Bits</u></span>
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Global Settings
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.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Data Bits
<span style="font-weight: normal;"><u>Use TX</u></span>
+
|-
 
+
| colspan="2" | &nbsp;
This property is of type ''True or false'' and can be referenced with the variable name ''UseTx''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Allows the Transmit pin to be enabled / disabled
+
| width="90%" | Stop Bits
 
+
|-
<span style="font-weight: normal;"><u>Use RX</u></span>
+
| colspan="2" | &nbsp;
 
+
|-
This property is of type ''True or false'' and can be referenced with the variable name ''UseRx''.
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Use TX
Allows the Receive pin to be enabled / disabled
+
|-
 
+
| colspan="2" | Allows the Transmit pin to be enabled / disabled&nbsp;
<span style="font-weight: normal;"><u>Transmit Pin</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''TXPin''.
+
| width="90%" | Use RX
 
+
|-
Pin assigned to transmitting data
+
| colspan="2" | Allows the Receive pin to be enabled / disabled&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Transmit Buffer Size</u></span>
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Transmit Properties
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
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | Transmit Pin
<span style="font-weight: normal;"><u>Receive Pin</u></span>
+
|-
 
+
| colspan="2" | Pin assigned to transmitting data&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''RXPin''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
Pin assigned to receiving data
+
| width="90%" | Transmit Buffer Size
 
+
|-
<span style="font-weight: normal;"><u>Receive Buffer Size</u></span>
+
| colspan="2" | Number of bytes that can be stored in the outgoing transmit buffer&nbsp;
 
+
|-
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''RXBufferSize''.
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Receive Properties
Number of bytes that can be stored in the incoming receive buffer
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Injector</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | Receive Pin
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Injector''.
+
|-
 
+
| colspan="2" | Pin assigned to receiving data&nbsp;
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.
+
|-
 +
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 +
| width="90%" | Receive Buffer Size
 +
|-
 +
| colspan="2" | Number of bytes that can be stored in the incoming receive buffer&nbsp;
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | API
 +
|-
 +
| colspan="2" | &nbsp;
 +
|}

Latest revision as of 17:19, 9 November 2022

Author MatrixTSL
Version 1.0
Category Comms: Interface


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.

Component Pack

COMMSC

Detailed description

No detailed description exists yet for this component

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

Fc9-comp-macro.png SendString
Sends an string to the transmit buffer 
Fc9-string-icon.png - STRING Data
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReceiveArray
Gets an array of values from the receive buffer. Returns number of values received. 
Fc9-u16-icon.png - UINT Values
 
Fc9-u16-icon.png - UINT NumValues
 
Fc9-u16-icon.png - UINT Timeout
Time in milliseconds to wait for data 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png SendArray
Sends an array of values to the transmit buffer 
Fc9-u16-icon.png - UINT Values
 
Fc9-u16-icon.png - UINT NumValues
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png UART_Timer_Process
Called as part of a timer interrupt at the specific UART baud rate. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReceiveValue
Gets a single value from the receive buffer 
Fc9-u16-icon.png - UINT Timeout
Time in milliseconds to wait for data 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png SendValue
Sends a single value to the transmit buffer 
Fc9-u16-icon.png - UINT Value
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CheckBuffer
Returns the number of values in the transmit or receive buffer 
Fc9-bool-icon.png - BOOL Buffer
0=Transmit / 1=Receive 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png ReceiveString
Gets a string from the receive buffer 
Fc9-u16-icon.png - UINT MaxChars
 
Fc9-u16-icon.png - UINT Timeout
Time in milliseconds to wait for data 
Fc9-string-icon.png - STRING Return


Fc9-comp-macro.png Initialise
Initialises the UART component pins ready to send and receive data 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png Global Settings
Fc9-type-16-icon.png Data Bits
 
Fc9-type-16-icon.png Stop Bits
 
Fc9-type-7-icon.png Use TX
Allows the Transmit pin to be enabled / disabled 
Fc9-type-7-icon.png Use RX
Allows the Receive pin to be enabled / disabled 
Fc9-conn-icon.png Transmit Properties
Fc9-type-5-icon.png Transmit Pin
Pin assigned to transmitting data 
Fc9-type-21-icon.png Transmit Buffer Size
Number of bytes that can be stored in the outgoing transmit buffer 
Fc9-conn-icon.png Receive Properties
Fc9-type-5-icon.png Receive Pin
Pin assigned to receiving data 
Fc9-type-21-icon.png Receive Buffer Size
Number of bytes that can be stored in the incoming receive buffer 
Fc9-conn-icon.png Simulation
Fc9-type-16-icon.png API