Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20717

BASCOM-AVR : Problem with Mid$ happens in chip but not in simulator. : NEWTOPIC

$
0
0
I'm trying to convert a hex string which is received from a modem into its uncoded ascii form, but when using Mid$, the last pair of characters are not extracted properly, dropping the last character of the string. The strange thing is that it works in the simulator, but when compiled and run in the micro-controller, the last character is missing. The debug print shows that this is happening at the Char = Mid(ar(3) , I , 2) line. The final extraction is START,2, instead of START,2,3 There are no interrupts in effect. Am I doing something wrong, or is there a bug somewhere? [code:1:ce06ad7398] $regfile = "m168def.dat" $crystal = 8000000 $baud = 9600 ' use baud rate $hwstack = 120 $swstack = 120 $framesize = 200 Dim Temp As Word Dim Device_id As String * 32 Dim Reply As String * 30 Dim I As Byte Dim Ar(4) As String * 30 Dim Acount As Byte Dim Pos As Byte Dim Ai(6) As Word Dim Char As String * 2 Dim Letter As Byte Dim Temp$ As String * 35 Dim Messageflag As Byte Dim Chrcount As Byte Ar(3) = "53544152542C322C33" 'Hex representation of START,2,3 Do Temp = Len(ar(3)) Temp$ = "" For I = 1 To Temp Step 2 Char = Mid(ar(3) , I , 2) Letter = Hexval(char) If Letter > 31 And Letter < 128 Then Temp$ = Temp$ + Chr(letter) 'Check for illegal characters End If Next Print "Command: " ; Temp$ 'Temp$ should be "START,2,3" Loop End [/code:1:ce06ad7398] [b:ce06ad7398][color=red:ce06ad7398](BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 )[/b:ce06ad7398][/color:ce06ad7398]

Viewing all articles
Browse latest Browse all 20717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>