After several hours testing, I will conclude this with information that there is a bug in serial input procedure.
So.
This is sending process:
[code:1:9eeb1b6432]do
waitms 1000
ADCHEX = "1234567890#"
print ADCHEX
loop[/code:1:9eeb1b6432]
It send 11 bytes data with CRLF at the end every 1000ms.
This is receiving program
[code:1:9eeb1b6432]'****************************************************************
' Compiler directives
'****************************************************************
$projecttime = 14
$regfile = "m1280def.dat" ' specify the used micro
$crystal = 18432000 ' used crystal frequency
$hwstack = 256
$swstack = 128
$framesize = 64
'****************************************************************
' MCU hardware configuration
'****************************************************************
Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin = Buffered , Size = 16
Config Serialout = Buffered , Size = 16
Config Com3 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin2 = Buffered , Size = 16 , Bytematch = 10
Config Serialout2 = Buffered , Size = 16
Open "COM3:" For Binary As #3
echo off
config input = crlf , echo = crlf
config input2 = crlf , echo = crlf
'************************************************************
' SUB's and function declarations
'************************************************************
'************************************************************
' Const definitions
'************************************************************
'************************************************************
' EEprom variables definitions
'************************************************************
'************************************************************
' Variables definitions
'************************************************************
Dim ADCHEX as String * 11
'************************************************************
' Program initialisation
'************************************************************
Enable Interrupts
'************************************************************
'''''''''''''''''''' Program start ''''''''''''''''''''''''
'************************************************************
Do
Loop
End
'************************************************************
'----------------- SUBS and Functions -----------------------
'************************************************************
'************************************************************
' INTERUPTS
'************************************************************
Serial2CharMatch:
ADCHEX = ""
Input #3 , ADCHEX
print ADCHEX
'***********************************************************
''''''''''''''''''''' END OF PROGRAM '''''''''''''''''''''''
'***********************************************************[/code:1:9eeb1b6432]
After execution this is terminal window output:
[code:1:9eeb1b6432]1234567890#
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
etc
etc[/code:1:9eeb1b6432]
I catch some row data from terminal window
[code:1:9eeb1b6432]
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
0A 31 32 33 34 35 36 37 38 39 30 0D 0A
etc...
[/code:1:9eeb1b6432]
So it is clearly visible missing and corrupting data, since each line start and ends with 0A, and missing 23 (#)
Then I added clearserial2 at end of interrupt procedure:
[code:1:9eeb1b6432]Serial2CharMatch:
ADCHEX = ""
Input #3 , ADCHEX
print ADCHEX
clear serialin2[/code:1:9eeb1b6432]
Now, terminal window show this data:
[code:1:9eeb1b6432]1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#[/code:1:9eeb1b6432]
Row data>
[code:1:9eeb1b6432]
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A
31 32 33 34 35 36 37 38 39 30 23 0D 0A[/code:1:9eeb1b6432]
WOW! Problem solved ... ?
Yes and NO ! :(
To catch all data from terminal window I should wait a small time before start receiving bytes so I put wait before enable interrupts:
[code:1:9eeb1b6432]wait 5
Enable Interrupts[/code:1:9eeb1b6432]
And this is again spoiled input routines, and again everythings back to old problem !!!! ????
This is terminal window before and after:
[code:1:9eeb1b6432]1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890#
1234567890# THIS IS LAST INPUT BEFORE I PUT "WAIT 5 "
(after programming new code)
PAUSE 5 SECONDS
1212345678 THIS IS AFTER
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
[/code:1:9eeb1b6432]
So there is definitely a BUG in serial buffer interrupt procedure, as is seen only in COM2, COM3 and possible in COM4. Somethings about sincronisation.
And only using INPUT and INPUTBIN.
Now Mark is on move.
Regards !
Mladen Bruck
P.S.
I have to use this code which work reliably, but I catch character # instead of LF
[code:1:9eeb1b6432]do
temp1 = Waitkey(#3)
incr temp
mid(ADCHEX , temp , 1) = chr(temp1)
temp1 = ISCHARWAITING(#3)
loop until temp1 = 0[/code:1:9eeb1b6432]
↧