Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Software UART parity error detection

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
dk9uv

Bascom Member



Joined: 07 Jan 2012
Posts: 19

germany.gif
PostPosted: Mon Jun 08, 2020 9:07 am    Post subject: Software UART parity error detection Reply with quote

Hi,

I wonder if it is possible to detect parity errors when using the software uart?
I changed the software uart example from BASCOM help to 7 bits and even parity (and port pins and crystal frequency).
Using the terminal programm Tera Term even and odd parity are both accepted and return the same result.

Best regards

Chris

Code:

$regfile = "m168def.dat"
$crystal = 7372800

$hwstack = 128
$swstack = 128
$framesize = 128


Dim B As Byte

Waitms 100


'Open a TRANSMIT channel for output

Open "comd.1:19200,7,e,1" For Output As #1

Print #1 , "serial output"



'Now open a RECEIVE channel for input

Open "comd.0:19200,7,e,1" For Input As #2

'Since there is no relation between the input and output pin

'there is NO ECHO while keys are typed



Print #1 , "Press any alpha numerical key"



'With INKEY() we can check if there is data available

'To use it with the software UART you must provide the channel

Do

   'Store in byte

   B = Inkey(#2)

   'When the value > 0 we got something

   If B > 0 Then

      Print #1 , Chr(b)                         'Print the character

   End If

Loop

Close #2                                         'Close the channels

Close #1



End


(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.8.2 )
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1197
Location: SYDNEY

australia.gif
PostPosted: Mon Jun 08, 2020 12:00 pm    Post subject: Reply with quote

Hello Chris dk9uv
Are you trying to detect transmission errors?
If so can you use CRC which I have made code for already.
Regards Paul vk2pl
Back to top
View user's profile
dk9uv

Bascom Member



Joined: 07 Jan 2012
Posts: 19

germany.gif
PostPosted: Mon Jun 08, 2020 1:55 pm    Post subject: Reply with quote

Hi Paul,

thanks for the quick reply.

The reason I am asking is that I want to implement the SDI-12 protocol which is used for some sensors. SDI-12 uses 7 bit and even parity.
CRC can optionally be included, see SDI-12 specification: http://www.sdi-12.org/current_specification/SDI-12_version-1_4-Jan-10-2019.pdf
and I have implemented that already.
I was just curious to know if I can detect parity errors as well.
So far I have never used parity, normally I take 8,N,1 settings for UART and use CRC.

With best regards

Chris
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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