RS232 Packet Framing

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
Penguin Fach
Posts: 4
Joined: Fri Feb 19, 2010 11:26 am
Contact:

RS232 Packet Framing

Post by Penguin Fach »

I am in the early stages of working on an intelligent serial data repeater/streamer that will permit a laboratory balance to communicate with a particular software package. The data stream is fixed at 2400 baud, 1 start, 7 data, 2 stop, no parity. The PIC that will be used is a 16F88 running at 19660800 and code development will be using standard e-blocks.

My question is how does Flowcode & the PIC handle the data packet framing, particularly the stop bits? It is not particularly clear from either the PIC or Flowcode data whether the stop bits are handled automatically or treated as part of the data stream. In past applications only the start bit has been implemented in the hardware of the processor and the data, stop and parity bits are realised in the user code but I know that this is not universally true with all processor families.

Am I correct in assuming that in order to get 7 data bits and 2 stop bits, I will need to work with 9-bit data and strip out the two LSB's of each received data packet in my code before being able to read the 7 data bits that I want (and conversely LSL x 2 plus add two low order bits to outgoing data)?

Regards, Frazer

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: RS232 Packet Framing

Post by Benj »

Hello,

You can configure Flowcode 4 to receive 7-bit data via the properties page.

Otherwise you will have to manually remove the most significant bit from the byte using an and instruction.

byte = byte AND 0x7F

Penguin Fach
Posts: 4
Joined: Fri Feb 19, 2010 11:26 am
Contact:

Re: RS232 Packet Framing

Post by Penguin Fach »

Hello Benj

Thanks for the reply. I would rather use 8 bits and strip out the MSB since 8-bit mode uses the USART. Given that the PIC USART's only support 8 & 9 bit operation, I presume that the 7-bit option in Flowcode is just bit-bashed and the USART is not used at all.

Of course the big disadvantage of using 8-bit mode is that the data will be unreadable in the data monitor windows since the sent and received characters will all have a '1' in the MSB, which will correspond to the first stop bit.

Adding stop bit control (and TX interrupt) would make the Flowcode RS232 module a lot easier to use.

Regards, Frazer

Post Reply