USART - testing the received data

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Dr_Zeus
Posts: 9
Joined: Mon Sep 06, 2010 11:23 am
Has thanked: 2 times

USART - testing the received data

Post by Dr_Zeus »

Dear All,

I'm very new to flowcode and have been away from basic programming for a long time, I'm working on a simple project with my pic (877A) to supplement a measurement on an oscilloscope on a K Line interface.

I'm using the 16F877A USART to receive BYTES and process them looking for a particular BYTE value of A7, anything else that comes along I will discard. When I see 0xA7 I want the PIC to wait for approx 500mS and then toggle an output HIGH. I am lucky in that A7 comes in with 3 other BYTES all of which I believe always a particular value e.g. 10 1A A7 20

I can't decide how to handle the data and sift through it, I have considered defining a string variable to receive the 4 BYTES, converting it to an Integer and subtracting it from static variable. If the result is zero then I know the sequence of BYTES contains the one I'm looking for and then I can proceed as required, if the result is not zero then I continue looking.

If I try this how do I ensure I don't miss any BYTES on the "line" while I'm performing the calculation?

Is there a better way of performing the function?

Thank you

Carl :)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: USART - testing the received data

Post by Benj »

Hello Carl,

The best way to do this would be a byte at a time so you don't miss any of the bytes. If you are doing a comparison of 4 bytes at a time then you have a 1 in 4 chance of starting on a wrong byte. If your using the UART hardware (RS232 component in hardware mode) then there shouldn't be any chance of missing data.
Attachments
Flowcode1.fcf
(6.5 KiB) Downloaded 324 times

Dr_Zeus
Posts: 9
Joined: Mon Sep 06, 2010 11:23 am
Has thanked: 2 times

Re: USART - testing the received data

Post by Dr_Zeus »

Many thanks Ben

Carl

Post Reply