Hi All,
I am using the Read Serial routine listed below with some tweaks. I an running a counter and when I see two bytes in a row of a certain pattern I allow the counter to increment to a value of 2. Any other time it should be either 1 or 0. the issue I have is my count of 2 never fires and yet I know it should with my incoming data. Any ideas why Count would never reach 2 if my pattern comes in ?
Thanks
Sub ReadSerial()
Dim Index As Byte
SDataSize = 0
While ISRRX.DataAvailable
SData(SDataSize) = ISRRX.ReadByte()
Inc(SDataSize)
Inc (ByteCount)
Wend
If SDataSize > 0 Then
For Index = 0 To (SDataSize - 1)
RXData(Index) = SData(Index)
Next
EndIf
If RXData(SDataSize-1) = $14 Then
Count = 1
Else
Count = 0
EndIf
If (RXData(SDataSize-1) = $63) And (Count = 1)Then
Count = 2
EndIf
End Sub
ReadSerial Issue
Moderators: David Barker, Jerry Messina
Slow it down ( a lot) and then debug it and work up the speed in steps. That will tell you something, whether code problems right away, or other possible propagation delays and/or (a)synchronization problems causing problems at high speed.
Check the datasheet for the percentage error at your oscillator and BRGH settings. A change in oscillator speed can sometimes land you in better asynch error conditions.
Check the datasheet for the percentage error at your oscillator and BRGH settings. A change in oscillator speed can sometimes land you in better asynch error conditions.