In applications where it is troublesome to set interrupt priority or the inherent unpredictability of interrupt is difficult to deal with, analog-to-digital converter (ADC) is more suitable to work in polling mode than in interrupt driving mode. This application note discusses the 16 bit of MAXQ3120 microcontroller in detail Σ-Δ Some matters needing attention when ADC works in polling mode. The implementation method of polling mode is demonstrated with assembly language source code.


MAXQ3120 is the first integrated dual channel, 16 bit Σ-Δ MAXQ microcontroller of analog-to-digital converter (ADC) (Fig. 1). The ADC makes this microcontroller especially suitable for single-phase meters, as well as any application requiring high-precision analog-to-digital conversion. For applications where it is troublesome to set interrupt priority or the inherent unpredictability of interrupts is not easy to handle, ADC is best to work in polling mode rather than interrupt driving mode.

16 bit Σ-Δ Performance characteristics and application analysis of analog-to-digital converter MAXQ3120

Figure 1. ADC function block diagram

The application note describes the use of MAXQ3120 ADC in polling mode, and discusses the programming precautions. A specific code example of ADC is given. The usage of MAXQ3120 multiplication accumulator (MAC) and the performance of LCD driver are also described. In this example, MAC completes the simple summation of ADC output (and subsequent averaging operation), and the average conversion result is displayed by LCD.

The code example given in this paper is written and tested for MAXQ3120, but it can also run on other related MAXQ devices containing similar resources. The whole development environment of the routine code adopts max-ide version 1.0 and MAXQ3120 evaluation board hardware version B.

Programming considerations

When the ADC of MAXQ3120 works in polling mode, the software design should consider the following characteristics of the converter: first, the designer must understand the meaning and usage of each bit in the ADC control register (adcn). Table 1 lists the bits of the register, and the function description of each bit is shown in Table 2. When an ADC output value is ready, the hardware will Asr1 or ASR0 position 1. At this time, the software can read a signed 16 bit value from the ADC output register (AD1 or AD0). If multiple conversions are completed before reading the output register, the new conversion result is not written to the output register. The sampling loss bit asl1 or asl0 is set and these conversion results are discarded. In the accompanying software (see the example code section below), the state of ASR0 bit is tested before each read of the output register. In this case, whether the output overflows or not is not important. Therefore, the status of sampling lost bits is ignored. At the same time, the gain is set to 1, and the reference voltage is provided by the internal band gap. In this example, only one analog-to-digital conversion channel (0) is enabled.

Another problem to be considered in the software is the establishment time of various modules in ADC. The modulator, sinc3 filter and reference bandgap buffer all have setup time. By starting the ADC at the beginning of the program and allowing it to run continuously, these setup times can occur only once. The software instance contains a software cycle delay of about 1s (based on 8MHz clock), which can slow down the program cycle and subsequent display refresh operation. This delay is also added after the ADC is started, so as to provide the establishment time for each module. Of course, this delay is much longer than the required setup time (see MAXQ3120 data for specific specifications). This code delay is only used to make it easier to implement.

MAXQ3120 includes a hardware module that can realize 16 bit x 16 bit word MAC function in one clock. This performance is comparable to many digital signal processors, enabling the MAXQ3120 to perform mathematical calculations quickly. This application does not need fast mathematical calculation function, but MAC helps calculate the average value of ADC output to smooth the output result and make the displayed value change more slowly. In order to obtain this average value, a multiplier is taken as 1 and 16 16 bit conversion results are transmitted to Mac. The sum of these 16 data words is stored in the accumulator. After the summation operation is completed, the result is divided by 16 (shift and addition) to calculate the average value. This average value is sent to the LCD for display. For a detailed description of MAC performance, see the MAXQ microcontroller user’s Guide.

Example code

The software supporting this application note is included in ADC_ file, which can be downloaded. The file includes: source code file ADC_ Polled.asm,My3120kit_ lcd.asm,maxq_ math.asm; Include the file; And max-ide project file ADC_ Polled.prj。 Extract these files to a public directory, assemble the software and execute it on the MAXQ3120 evaluation board.

Apply a variable voltage to the ADC input of MAXQ3120, and then observe the display results on LCD. This application is very useful and can provide more information. A variable voltage of suitable range can be generated by using a fixed resistance and a potentiometer. The schematic diagram of component connection of the circuit is shown in Figure 2. The MAXQ3120 evaluation board provides a small prototype area near the DB-9 serial connector. The edge of the prototype area also has vias connecting avcc and agnd routing. After adding this simple circuit, a voltage of 0 to 0.823v can be applied at the input of analog channel 0 (an0 +) (the maximum value is close to 1V). As shown in the schematic diagram, the an0 input is connected to agnd to provide a reference level.

Figure 2. Circuit diagram of voltage divider generating ADC input


The MAXQ3120 microcontroller includes a dual channel, 16 bit Σ-Δ ADC can be used in all systems requiring high-precision analog-to-digital conversion. This application note describes some ADC features that need to be considered when working in polling mode. The example code demonstrates how to use ADC in polling mode. The example code also demonstrates other MAXQ3120 features, including MAC hardware and direct LCD driver performance. MAXQ3120 evaluation board is used as the platform of the software. By adding a circuit composed of two common components, the user can add a variable voltage to the ADC input and observe the display result of LCD on the evaluation board.

Responsible editor: GT

Leave a Reply

Your email address will not be published. Required fields are marked *