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:

Highest increase in global cyberattacks in two years
Information Security News & Events
Check Point Global Research released new data on Q2 2024 cyber-attack trends, noting a 30% global increase in Q2 2024, with Africa experiencing the highest average weekly per organisation.

Read more...
Microchip enhances digital signal controller lineup
Future Electronics DSP, Micros & Memory
Microchip Technology has added the dsPIC33AK512MPS512 and dsPIC33AK512MC510 Digital Signal Controller families to its dsPIC33A DSC product line.

Read more...
Ultra-low-power wireless module
Altron Arrow Telecoms, Datacoms, Wireless, IoT
The STM32WBA5MMG from STMicroelectronics is an ultra-low-power, small form factor, certified 2,4 GHz wireless module that supports Bluetooth LE, Zigbee 3.0, OpenThread, and IEEE 802.15.4 proprietary protocols.

Read more...
MCX C Series development board
Avnet Silica DSP, Micros & Memory
The FRDM-MCXC444 is a compact and scalable development board for rapid prototyping of MCX C444 MCU from NXP Semiconductors.

Read more...
16-channel multicell battery monitor
Altron Arrow Power Electronics / Power Management
The ADBMS6830B is a multicell battery stack monitor that measures up to 16 series-connected battery cells with a lifetime total measurement error of less than 2 mV.

Read more...
The power of PKI and private sector innovation
Access Control & Identity Management News & Events Government and Parastatal (Industry)
At the recent ID4Africa 2025 Summit in Addis Ababa, the spotlight was firmly on building secure, inclusive, and scalable digital identity ecosystems for the African continent.

Read more...
Bringing Bluetooth Channel Sounding to automotive and beyond with KW47
Altron Arrow Telecoms, Datacoms, Wireless, IoT
NXP’s new Channel Sounding-certified KW47 and MCX W72 wireless MCUs are set to help automakers with distance measurement, bringing an additional ranging solution for car access and autonomous systems, and will be utilised across a broader spectrum of applications.

Read more...
Redefining entry-level MCUs
NuVision Electronics DSP, Micros & Memory
The company positions the GD32C231 series as a ‘high-performance entry-level’ solution designed to offer more competitive options for multiple applications.

Read more...
Wi-Fi 6 and Bluetooth LE coprocessor module
Altron Arrow Telecoms, Datacoms, Wireless, IoT
The ST67W611M1 from STMicroelectronics boasts an all-in-one design which, together with its capabilities, contribute to making it an attractive choice for IoT edge devices requiring a single-chip solution.

Read more...
Wi-Fi 6 plus Bluetooth LE SoC
Altron Arrow Telecoms, Datacoms, Wireless, IoT
Silicon Labs’ SiWx917M SoC is the company’s lowest power Wi-Fi 6 SoC, ideal for ultra-low power IoT wireless devices using Wi-Fi, Bluetooth, Matter, and IP networking for secure cloud connectivity.

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