delay function problem

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

delay function problem

Post by howard123 »

Hello all

Not sure if this should be in the bug report but I am having strange behaviour when using the delay function in conjunction with a UART.

As you can see from the flowcode image a 4mS delay is placed between UART sends but on the logic analyser image, measuring target hardware, it is actually 2mS. This is with a baud rate of 9600. Changing the baud rate to a higher speed makes the delay longer and it gets close to 4mS at 115200.

My clock is defined correctly at 16MHz.

Many thanks
Howard

FC 7.2.0.5
PIC18F46K22
flowcode.JPG
flowcode.JPG (51.32 KiB) Viewed 4384 times
Attachments
logic ana.JPG
logic ana.JPG (34.48 KiB) Viewed 4384 times

User avatar
Bachman
Posts: 116
Joined: Sun Sep 07, 2014 11:37 am
Location: Hungary
Has thanked: 9 times
Been thanked: 53 times
Contact:

Re: delay function problem

Post by Bachman »

The flowchart command sends the charaters to a buffer (SW, HW, both?) then waits 4 ms, the main process does not wait for the UART module to finish the job. This is why you see more pause at higher UART baudrate. I think.
Delay time.jpg
Delay time.jpg (36.14 KiB) Viewed 4368 times

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: delay function problem

Post by howard123 »

Thanks I understand now
regards
howard

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: delay function problem

Post by Benj »

Hi Howard,

If you wanted to wait until the UART byte has finished being sent before starting your delay then you could use this following C code in a C icon.

UART Channel 1

Code: Select all

while (TXSTA1bits.TRMT);
UART Channel 2

Code: Select all

while (TXSTA2bits.TRMT);

Post Reply