This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIP Regarding Use of SET/CLEAR registers

This is probably obvious - but it just struck me because I'm making some latency measurements by toggling an I/O pin.

The GIO module has separate SET and CLEAR registers for GIO data output;  which are intended to help avoid corruption when

two tasks are sharing pins controlled by the same port, and one task might interrupt the other in the middle of a read-modify-write sequence.

Instead of performing a read-modify-write to say clear bit 0 without changing any of the other bits in the port, you can simply write a 0x1 to

the CLEAR register.   This was the original reason for including these registers.


However, it is also significantly faster if you use the SET / CLEAR feature than acutally performing separate read and write operations.

This is especially true on the TMS570 and other processors in its performance class where it may take many cycles to have data returned

from a peripheral.  If you use the read-modify-write sequence, you need to wait for the data to be returned before your code continues on.

If however you simply use one of the SET or CLEAR register views - the write can be issued and the processor can then continue its work with

little delay.  No need to wait many cycles for data to be returned from the peripheral.

 

Long winded - but an observation:  It's probably a good idea to use the SET/CLEAR registers in a peripheral whenever they are available, even if you aren't multi-tasking; because they'll also be faster.    Most of the peripherals on the TMS570 have them.