Joined: 24 Feb 2019 Posts: 13 Location: Rio de Janeiro
Posted: Fri Nov 22, 2019 3:17 pm Post subject: Soft Serial UART hang after reconnect
My 328p with bellow code works fine to receiving the serial input but if there are a momentary disconnection from this input the processor hangs then only reconnecting after a reset.
I have tryed the timeout but it seems does not work.
Obs. The input pin PORTC.1 have a 1k series resistor. I dont believe this could matter in this issue.
Dim serin_timeout as long
Dim S As String * 8
Dim I As Word
do
serin_timeout = 50000
Serin S , 1 , PortC , 1 , 9600 , 0 , 8 , 1 'testada a saida digital no pino analogo
I = Val(s) 'isola só os numeros da string transformando para numerico
S = Str(i) 'numérico de volta para string
S = Format(s , "0000") 'formata a string
S = S + " mm" 'soma a string
Print S
Waitms 50
The serin is set as input, so if the signal is momentary disconnected then this input pickup noise etc. and will do strange things.
Try 10K pulldown resistor to hold the serin in known active state when the signal disconnect. _________________ www.evertdekker.comBascom code vault
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum