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...
High reliability memories
Altron Arrow DSP, Micros & Memory
Infineon’s mil-temp memories offer a wide selection of volatile and non-volatile memories for applications that meet QML-Q certifications and offer support for mil-aero applications.

Read more...
Amendments to the Private Security Industry Regulations
Technews Publishing Agriculture (Industry) News & Events Associations
SANSEA, SASA, National Security Forum, CEO, TAPSOSA, and LASA oppose recently published Amendments to the Private Security Industry Regulations regarding firearms.

Read more...
Altron celebrates 60th birthday with a call to rebuild Johannesburg
Altron Arrow News
Altron is celebrating its 60th birthday by honouring Johannesburg’s heritage and encouraging business, government and civil society to come together and respond to our President’s call to rebuild Johannesburg.

Read more...
KIOXIA pioneer new 3D Flash technology
EBV Electrolink DSP, Micros & Memory
KIOXIA Corporation and Sandisk Corporation have pioneered a state-of-the-art 3D flash memory technology, setting the industry benchmark with a 4,8 Gb/s NAND interface speed, superior power efficiency, and heightened density.

Read more...
Artificial intelligence meets embedded development
Avnet Silica DSP, Micros & Memory
Microchip Technology is leveraging the power of artificial intelligence (AI) to assist software developers and embedded engineers in writing and debugging code with the launch of its MPLAB AI Coding Assistant.

Read more...
Embedded module for AI vision applications
Rugged Interconnect Technologies DSP, Micros & Memory
The TQMa95xxSA supports AI/ML with vision applications through an integrated NPU and an image processor unit.

Read more...
High-speed Flash for SoC applications
NuVision Electronics DSP, Micros & Memory
GigaDevice has unveiled the GD25NE series of dual-power supply SPI NOR Flash chips, designed specifically for 1,2 V system-on-chip (SoC) applications.

Read more...
Super-fast H.264 encoder FPGA core
EBV Electrolink DSP, Micros & Memory
An ITAR-compliant H.264 core designed for AMD FPGAs provides baseline H.264 support and is currently the smallest and fastest FPGA core in the industry.

Read more...
Reference board for cardio monitoring
Altron Arrow Telecoms, Datacoms, Wireless, IoT
The STDES-ESP01 reference board from STMicroelectronics demonstrates the capability of the ST1VAFE6AX and ST1VAFE3BX biosensors to detect ECG and SCG signals.

Read more...