here the Firewing 32 version of UartBuffer2.BAS module
Download the compressed file and, with Firewing IDE opened, dragged it on editor window.. this copy the module in your "UserLibrary\MCU32" folder
EXAMPLE :
- Code: Select all
imports UartBuffer2
imports Uart2
imports Tick
' this event handler is triggered when data is received - it gives
' the program the opportunity to accept or reject the incoming byte
' or modify the data in some way - this example changes all space
' characters to underscore...
Sub OnData(ByRef Data As Byte, ByRef Accept As Boolean) Handles RX2.OnData
Dim DataIn As Byte = Data
If DataIn = cbyte(" ") Then
Data = "_"
End If
End Sub
' this event is fired if the RX buffer overruns...
Sub OnOverrun () Handles RX2.OnOverrun
End Sub
' main program...
Sub Main()
dim mTickPrev As uinteger = 0
UART2.SetBaudrate(UART2.Baudrate.Is9600) ' set baudrate
pps.enableRX2()
pps.enableTX2()
RX2.Start() ' start buffering data
' loop forever to prevent program
' from terminating...
mTickPrev = tick.Time()
While True
If RX2.DataAvailable() Then ' if data is available
Console.Write(RX2.ReadByte()) ' then echo back
End If
End While
End Sub