Problem I see is that using Hex() or Str() to convert a number to string and then outputting the number interacts with the UART2 code and freezes the UART2 write functionality.
The program at the bottom of this post illustrates the problem. (This is a small version of what I am working on, but it fails the same way as the larger program)
I've marked the problem area with '### symbols in the program.
If the lines within the ### highlight are:
- Code: Select all
TByte = 44
//TempStr = Hex(tByte)
TempStr = "99"
UART2.Write("Fields: ",TempStr,13,10)
The program executes fine and the terminal screen looks like:
OK
<A,D,C,P>?
Rcvd test 123
Fields: 99
<A,D,C,P>?
I have entered the response test 123 after the ? symbol and the program has echoed it back. The code within the ### executes
and displays Fields: 99 and the main prompt returns for the next data entry sequence.
However .... if I change the code within the ### to:
- Code: Select all
TByte = 44
TempStr = Hex(tByte)
//TempStr = "99"
UART2.Write("Fields: ",TempStr,13,10)
None of the prompt is displayed and entering test via the terminal results in no prompt.
This looks to me like the compiler generates bad code with this sequence that somehow mangles the UART2 functionality as if there was just a problem with the conversion into a string representing the hex display the prompt would appear for the initial data entry.
Here's the full program demonstrating the problem.
- Code: Select all
' Imports section...
Imports Strings
imports Uart
imports Uart2
' Declarations...
'Const
'-----
'Var
'---
Sub Main()
Dim TByte as Byte
Dim TempStr as String
Dim Rstr as String
UART2.ReadTerminator = 13
Uart.SetBaudrate(Uart.Baudrate.Is38400)
Uart2.SetBaudrate(Uart2.Baudrate.Is9600)
Delayms(100)
UART2.Write("OK",13,10)
While True
Delayms(500)
UART2.Write("<A,D,C,P>? ",13,10)
Uart2.Read(RStr)
Uart2.Write("Rcvd ",RStr,13,10)
Delayms(5)
'#################################################
'Problem is in lines below.
'Program executs as expected with TempStr = 99
'Fails with TempStr = Hex(tByte)
'#################################################
TByte = 44
//TempStr = Hex(tByte)
TempStr = "99"
UART2.Write("Fields: ",TempStr,13,10)
End While
End Sub
