Home Articles The power of autonomous peripherals: achieving low consumption in time...

The Power of Autonomous Peripherals: Achieving Low Power in Real Time

Core Independent Peripherals (CIPs) are autonomous, interconnected, and intelligent peripherals. Thanks to CIPs, the microcontroller no longer needs to interact with the CPU to execute tasks, which offers several benefits to the application. First, the CPU is not needed for communication between peripherals; the kernel can remain idle and the flow of software does not have to be interrupted. Naturally, if the kernel is idle and no software is needed, the current consumption of the application will be lower. The CPU is the part of the microcontroller that draws the most current; therefore, the use of CIP reduces energy consumption. Second, CIPs do not cause interruptions and this allows for faster communications overall. If the CPU core is running software and it needs to be interrupted by the peripheral to perform a certain action, it takes a lot of time.
The interrupt needs three clock cycles + two clock cycles for the relative jump and could use several cycles for the context switch to save the data in the stack registers depending on the application. CIPs allow communication to be much more than if the kernel had to be interrupted. Third, the use of CIP shortens the time to market. You have to write less software as the hardware itself can take over. This reduces the risk of software bugs and requires less software validation. Therefore, the product development time is shorter than if CIPs are not used. In AVR® microcontrollers, all CIPs are connected via the Event System, in which a multiplexer connects the event generator and the event user. There are synchronous and asynchronous events. Asynchronous events take less than one clock cycle, and synchronous events take two clock cycles. Numerous peripherals can be connected to the event system to be CIP: timers, Real Time Counter (RTC), Periodic Interrupt Timer (PIT), Custom Configurable Logic (CCL). ), analog comparators (Analog Comparator, AC), A/D converters, UART (Universal Synchronous/Asynchronous Receiver/Transmitter) and general purpose I/O (General Purpose Input/Outputs, GPIO).
Use of CIPs
CIPs need to be configured only once before use. The CPU executes the instruction to perform the correct initialization of the Event System and the necessary peripherals.
Debounce/Debounce
Some applications still use a button as input these days, and each button requires debounce logic or a software program, thus obtaining a stable signal. Debouncing is easy for the AVR microcontroller in software and can be accomplished by delays and/or logic in the software program. The software is not complicated, but it uses CPU resources. Whether or not the button has been pressed can be checked by polling or with an interrupt from the GPIO driver. In both cases it takes time and CPU to complete the debouncing.
Debounce/delay with CCL filter
With CIPs, debouncing can be completed without resorting to the CPU: all that is required is Custom Configurable Logic (CCL). The GPIO to which the button is connected is configured as an asynchronous event generator. The CCL will be the user of the event. The signal from the GPIO pin to the CCL input will be transmitted without delay. The CCL truth table is configured such that the output is equal to the input. The output of the truth table is routed to the filter (see Figure 1). Random pulses (glitches) can be removed from the input signal, and the filter delay can be set to two to five clock cycles (peripheral clock or alternate clock) for the output signal. If a slow 32 kHz clock is used, a delay of 1,5 ms can be obtained. It is also possible to extend the delay time with a different clock or timer.
Delay with a timer
 For example, Timer/Counter B (TCB) is set to Single-Shot mode. If the timer receives an event signal, it starts counting until it reaches its maximum value and stops it. The output of the TCB is connected to the CCL. In the CCL the desired combination of the delay signal can be made, which allows to obtain a very flexible delay. Each new event that arrives at the TCB causes it to start counting again.
generation of dead time
Dead time is used in applications with series switches between power and ground. If both are activated at the same time, a short circuit occurs. An example of this is the half-bridge configuration used in motor control. Depending on the application, the dead time will take place between commutations or between PWM (Pulse-Width Modulation) pulses. Dead time between PWM pulses is required, for example, in sinusoidal control and between commutations for 1-pole brushless DC motors. The dead time between PWM pulses can be generated by the timer TCD (Time Code Display). To generate dead time between switches, two timers are needed, the CCL and the analog comparator. Figures 2 and 3 represent the logic of the CCL truth table. The TCA timer generates the PWM signal that serves as the basis for motor control. The analog comparator is connected externally to the motor Hall sensor and internally via the event system to the TCB timer. The TCB timer generates the dead time signal if it gets a signal from the analog comparator. The CCL combines the signal from TCA (PWM), TCB (dead time) and the analog comparator. The input signals can be selected directly in the CCL setup and there is no need to use the Event System. There are physical connections between these modules. The CCL then generates two PWMs (see Figure 4) to control the switches of the motor, which operates without the intervention of the CPU. For more technical information see AVR application note AVR42778.
Auto power off PWM signal
Many applications need to monitor current consumption so that it does not exceed a maximum level. This can easily be done with the analog comparator, which measures voltage (current in resistance) via a tap register. If it exceeds a preconfigured threshold, the PWM signal should stop immediately. The two examples shown below use CIP. The PWM output signal can be stopped when overcurrent is detected without CPU intervention.
Example of LED lighting with TCA and CCL
Timer/Counter A0 generates the PWM for the LED. The analog comparator is used to detect overcurrent and the CCL combines these signals, and if PWM is detected it stops automatically. The analog comparator and TCA0 are connected through the Event System to the CCL. The output signal of the analog comparator and the PWM configure the truth table of the CCL (see Figure 5). The PWM signal is input if the event signal is formed such that the analog comparator is zero. If an overcurrent is detected, the analog comparator event signal is one and the output is zero as long as an overcurrent exists.
Example of controlling a motor with the TCD
A brushless DC motor is controlled by the TCD timer, which generates the PWM signals on two channels + two complementary channels to drive the MOSFET transistors in a half-bridge configuration. The analog comparator is used to detect motor overcurrent with a shunt between the motor and ground. The analog comparator is connected via the Event System to the Timer/Counter D0 (TCD). The functions of the TCD include fault management. If the analog comparator threshold is exceeded (overcurrent detected) an event is signaled to the TCD and the PWM stops automatically.
Flight time measurement
The time-of-flight measurement is used to measure the distance a signal travels. The measurement starts when the signal leaves the transceiver and stops when it is detected by the receiver. With the time and the known m/s of the signal, the distance can be calculated. In the example shown below, the distance is measured with an ultrasonic signal. For this we need the CIP TCA0, TCB0, TCS0, analog comparator and 2x CCL, and then calculate the time of flight without resorting to the CPU. Figure 6 shows how Lookup Table 1 (LUT1) generates the transmitted signal. TCA Out generates the PWM signal and TCD Out B is the transmit mask. The inverted transmit mask and PWM are ANDed together and then generate the transmitted signal, which is shown in the truth table for LUT1. LUT 0 generates the reflected signal. AC Out indicates activity on the receive line and TCD Out A is the receive mask. The inverted receive mask and “receive line” are ANDed and generate the reflected signal, which is shown in the LUT0 truth table.
The SR flip-flop is reset with the first transmitted signal and starts the counter on TCD. With the signal coming from the reflected signal, and when the SR flip-flop is turned on, the TCD counter stops. Flight time is now stored in the TCD counter value without resorting to the CPU, which is only needed to calculate distance when flight time is multiplied by signal velocity. For more technical information on ultrasonic distance measurement, see AVR application note AVR42779.
Conclusion
Microchip's new ATiny1617/1616/1614/817/816/814/417 series of microcontrollers add innovative Core Independent Peripherals (CIPs) to the tinyAVR® family of microcontrollers. Thanks to these CIPs, an application can react in real time, with less software load and lower current consumption than without CIP. The examples shown demonstrate that CIPs are easy to configure and that their real-time operation is faster and consumes less power than software-based solutions. Even with much higher performance microcontrollers, this level of real-time performance cannot always be achieved and, if possible, the consumption would be several times higher.