What is the FLUSH Command Used For?

The XJTAG system optimises writes to the hardware by queuing a series of writes. There are several events that can cause these writes to be transmitted to the hardware; when the queue becomes full, when a read is requested from the hardware or after a timeout.

There are some circumstances in which you may need to write to a device and then wait for a specific period before reading back a value, for example, writing to Flash then waiting for a period before reading back the status.  The FLUSH command can be used to force the write to be performed before the delay.

For example, the following code fragment will not produce the expected result, because the SET WR := 1 write operation will not be performed until the SET status := DATA[6] read statement is encountered after the delay.

// Write the data.
SET DATA := write_data, WR := 1;
// Wait 100 ms.
timeout := NOW + 100;
DO WHILE NOW < timeout END;
// Get the status.
SET status := DATA[6];

A FLUSH command should be inserted before the delay to ensure that the sequence is performed as expected:

// Write the data.
SET DATA := write_data, WR := 1;
// Ensure data is written.
FLUSH;
// Wait 100 ms.
timeout := NOW + 100;
DO WHILE NOW < timeout END;
// Get the status.
SET status := DATA[6];

Want to be the first to know of new eBooks and JTAG Resources?

Find out how XJTAG can help you test your PCB faster
From Prototype To Manufacture