In this 'Tips 'n Tricks' article from Microchip Technologies, the company describes a method of structuring faster code for detecting change.
When using a comparator to monitor a sensor, it is often just as important to know when a change occurs as it is to know what the change is. To detect a change in the output of a comparator, the traditional method has been to store a copy of the output and periodically compare the held value to the actual output to determine the change. An example of this type of routine is shown in Figure 1.
Figure 1. Routine 1
This routine requires five instructions for each test; nine instructions if a change occurs and one RAM location for storage of the old output state. A faster method for microcontrollers with a single comparator is to use the comparator interrupt-flag to determine when a change has occurred.
Routine 2 (Figure 2) requires two instructions for each test; three instructions if a change occurs and no RAM storage. If the interrupt flag cannot be used or if two comparators share an interrupt flag, an alternate method that uses the comparator output polarity bit can be used.
Figure 2. Routine 2
Routine 3 (Figure 3) requires two instructions for each test; five instructions if a change occurs and no GPR storage.
Gallagher Security releases new fence controllers
Perimeter Security, Alarms & Intruder Detection News & Events
Gallagher Security has announced the release of its new F5 and F6 Fence Controllers, marking the latest generation of enhanced-safety, monitored-pulse fence technology, designed to meet the demands of modern security environments.
Read more...Paxton set to launch game-changing new system Paxton
Access Control & Identity Management News & Events
Access control is evolving fast. Installers and end users are looking for systems that are simple to install, easy to manage remotely, and flexible enough to scale. In response, Paxton is exploring how emerging technologies can reshape access control.
Read more...Proactive estate security in Cape Town neaMetrics OneSpace Technologies Technews Publishing SMART Security Solutions Fang Fences & Guards ATG Digital
Editor's Choice News & Events Integrated Solutions Infrastructure Residential Estate (Industry) SMART Security Solutions started the year with our annual SMART Estate Security Conference in Cape Town on 26 February 2026. Held at Anna Beulah Farm, the conference saw a number of delegates enjoying the farm’s excellent cuisine, while listening to outstanding presenters.
Read more...GigaDevice expands GD25UF Series density NuVision Electronics
DSP, Micros & Memory
GigaDevice has announced the expanded density range of its GD25UF series 1,2 V ultra-low power SPI NOR Flash, now spanning from 8 Mb to 256 Mb.
Read more...ARINC 429 line driver evaluation board ASIC Design Services
DSP, Micros & Memory
Holt Integrated Circuits have announced the release of the ADK-85104 Evaluation Board, a compact, ready-to-use platform designed to help engineers rapidly evaluate and characterise Holt’s HI-85104.
Read more...Highly integrated 24-channel mixed signal IC EBV Electrolink
DSP, Micros & Memory
Microchip Technology has announced the LX4580, a 24-channel mixed-signal IC designed to replace multiple discrete components with a single device that supports synchronised data acquisition, fault monitoring, and motor control.
Read more...Lower-power Thread and BLE connectivity iCorp Technologies
DSP, Micros & Memory
Espressif has released the ESP32-H21, a low-power wireless SoC aimed at Thread, Matter, Zigbee, and Bluetooth LE device designs.
Read more...Touch-enabled 32-bit MCU EBV Electrolink
DSP, Micros & Memory
Microchip’s PIC32CM PL10 microcontroller family expands the company’s Arm Cortex-M0+ portfolio, delivering a compact, low-power 32-bit platform designed for cost-sensitive embedded applications.
Read more...Compact 6 A automotive buck converter Altron Arrow
Power Electronics / Power Management
Delivering up to 6 A of continuous output current, the DCP0606Y from STMicroelectronics enables efficient regulation of low-voltage rails commonly used in modern vehicle electronics and industrial systems.
Read more...Build smarter with UNO Q Electrocomp Express
DSP, Micros & Memory
The Arduino UNO Q’s hybrid design combines a Linux Debian-capable microprocessor with a real-time STM32U585 microcontroller making it the perfect dual-brain platform for the next innovation.
While every effort has been made to ensure the accuracy of the information contained herein, the publisher and its agents cannot be held responsible for any errors contained, or any loss incurred as a result. Articles published do not necessarily reflect the views of the publishers. The editor reserves the right to alter or cut copy. Articles submitted are deemed to have been cleared for publication. Advertisements and company contact details are published as provided by the advertiser. Technews Publishing (Pty) Ltd cannot be held responsible for the accuracy or veracity of supplied material.