DSP, Micros & Memory


Microcontroller comparators: method of faster code for detecting change

20 October 2004 DSP, Micros & Memory News & Events

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
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
Figure 2. Routine 2

Routine 3 (Figure 3) requires two instructions for each test; five instructions if a change occurs and no GPR storage.

Figure 3. Routine 3
Figure 3. Routine 3



Credit(s)



Share this article:
Share via emailShare via LinkedInPrint this page

Further reading:

Protect the integrity of critical video evidence
Surveillance News & Events
SWEAR has announced the Community Video Integrity Project, a new initiative designed to help cities and public agencies proactively protect the integrity of critical video and establish a verifiable record of authenticity from the moment it is captured.

Read more...
ONVIF strengthens authenticity of video surveillance footage
Surveillance News & Events
Amid a rising tide of manipulated and AI-generated footage, the add-on will equip the surveillance industry with a shared, standards-based way to establish where video came from and whether it has remained unaltered.

Read more...
Detect procurement fraud before losses escalate
Security Services & Risk Management News & Events Financial (Industry) Editor's Choice
Organisations need to move procurement fraud prevention closer to the point where suspicious activity occurs, rather than relying primarily on investigations after money has already been lost, according to SAS and FACTS Consulting.

Read more...
More room to scale
Altron Arrow Power Electronics / Power Management
With the latest STM32H5 lines from STMicroelectronics, you can now scale within the same platform, from a compact 1 Mbyte device to higher-memory MCUs for graphics-rich and feature-heavy designs.

Read more...
1 GHz crossover MCU with Arm Cortex Cores
Future Electronics DSP, Micros & Memory
i.MX RT1170 Crossover MCUs, from NXP Semiconductor, are dual-core devices featuring an Arm Cortex-M7 and Arm Cortex-M4 for real-time microcontroller (MCU) performance and high integration for automotive, industrial and IoT applications.

Read more...
NECTO studio update 7.5.0
DSP, Micros & Memory
MIKROE have continued their collaboration with Renesas by introducing support for the RL78 architecture in NECTO Studio, expanding the IDE beyond its existing MCU platforms.

Read more...
Multi-constellation GNSS module in a legacy-compatible footprint
Altron Arrow Telecoms, Datacoms, Wireless, IoT
Telit Cinterion has announced the SE869eK2L, a single-frequency L1 GNSS module designed to help device manufacturers upgrade legacy positioning designs with improved performance and cost efficiency, while preserving design continuity.

Read more...
Compact SSI family for industrial automation
Altron Arrow Passive Components
Infineon Technologies has introduced the ISSI20BxxF Solid State Isolator (SSI) family, bringing solid-state isolation technology into high-volume applications traditionally served by photovoltaic isolators (PVIs), photovoltaic relays (PVRs), and electromechanical relays (EMRs).

Read more...
Rev 2.0 PolarFire FPGA ethernet sensor bridge
Altron Arrow Computer/Embedded Technology
Smaller, multi-camera platform enables scalable Ethernet architectures for NVIDIA Edge AI systems, while lowering power, cost and integration complexity.

Read more...
Universal IR receiver module
Altron Arrow Telecoms, Datacoms, Wireless, IoT
Vishay Intertechnology has introduced a new series of infrared (IR) receiver modules for IR remote control applications, which feature a wide modulation frequency acceptance from 30 kHz to 68 kHz.

Read more...









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.




© Technews Publishing (Pty) Ltd | All Rights Reserved