What could cause glitches on an output port?

If you have defined your own variables to reside at the port locations, make sure you qualify these variables as volatile. Without this, bits within the port, or the entire port byte value itself, may not be accessed atomically (in one instruction). For example, the most efficient way to write a bit on 8-bit devices is to set the bit, then optionally clear it if required. This takes the least amount of code but can lead to a bit changing state twice.

There could also be problems with cached copies of the port value being used if you should read from the port. For example:

If you are using the definitions for the ports that become available after including, then these are already correctly qualified and you do not need to modify these definitions.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.