TI E2E Community
Hercules™ Safety Microcontrollers
Hercules™ Safety Microcontrollers Forum
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.
If my reply answers your question please click on the green button "Verify Answer".
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.