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
delay function problem
Moderator: Benj
- 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
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.
- 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
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
UART Channel 2
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);
Code: Select all
while (TXSTA2bits.TRMT);
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel