AVR Configurable Custom Logic As A Frequency Divider At 4x Chip’s Clock Speed

What a time to be alive when you can find inexpensive microcontrollers that come with programmable(ish) logic that can operate independently of the system clock. [David Johnson-Davies] recently built a proof of concept using the Configurable Custom Logic (CCL) that is available in some of the newer AVR microcontroller designs. It’s a simple implementation, a set of frequency dividers that blink three LEDs with up to a 90 MHz input signal. But the simplicity is the reason to love his write-up — you can wrap your head around it right away.

There are four lookup table (LUTs) used to form the frequency divider. Think of these like a NAND or XOR gate, but you get to decide how the output truth tables will perform. The output is fed into a sequencer which can be configured as a D/JK flip-flop or a D/RS latch, plus you can specify the signal edge, and of course define the clock source. An interesting trick here is to hold the G input of both D flip-flops high by feeding them LUTs set to all ones. Note that the output of the first divider (PA3) is feeding the external input (PD2) of the second divider.

While the CCL is configured using the C code you flash to the microcontroller, it’s a hardware peripheral capable of operating independent of the chip’s system clock. The AVR128DA28 that’s used here tops out at 24 MHz (double that if you use the PLL) but [David] got reliable results from his clock divider feeding a signal as high as 90 MHz to the input pin. Of course you have the option of feeding internal clock signals to the CCL, but that wouldn’t seem nearly as interesting here. For the demo, [David] is actually toggling an IO pin which is connected to PA2 as the external input for the logic. Make sure you click through to his write-up linked above as he does an excellent job of walking through the sample code (just a couple-dozen lines to set this all up). Here’s the datasheet for this chip (PDF, page 447 for pertinent registers) and for a deeper dive the appnote on CCL (PDF).

So what is this all good for? We already saw an answer to that question back in January when [SM6VFZ] used the CCL peripheral to build a software-defined switch-mode converter. How awesome is that?

AVR Microcontroller Doubles Up As A Switching Regulator

[SM6VFZ] designed, built and tested a switched-mode DC-DC boost regulator using the core independent peripherals (CIP) of an ATtiny214 micro-controller as a proof of concept, and it looks pretty promising!

A Buck, Boost, or Buck-Boost switching regulator topology usually consists of a diode, a switching element (MOSFET) and an energy storage device (inductor/capacitor) in the power path, and a controller that can measure the output voltage, control the switching element and add safety features such as current limiting and temperature shutdown. A search for switching regulators or controllers throws up thousands of parts, and it’s possible to select one specifically well suited for any desired application. Even so, the ability to use the micro-controller itself as the regulator can have several use cases. Such an implementation allows for a software configurable switch-mode regulator and easy topology changes (boost, buck, fly back etc.).

The “Getting Started with Core Independent Peripherals on AVR®” application note is a good place to get an overview of how the CIP functionality works. Configurable Custom Logic (CCL) is among one of the powerful CIP peripherals. Think of CCL as a rudimentary CPLD — a programmable logic peripheral, which can be connected to a wide range of internal and external inputs such as device pins, events, or other internal peripherals. The CCL can serve as “glue logic” between the device peripherals and external devices. The CCL peripheral offers two LookUp Tables (LUT). Each LUT consists of three inputs, a truth table, a synchronizer, a filter, and an edge detector. Each LUT can generate an output as a user programmable logic expression with three inputs and any device that have CCL peripherals will have a minimum of two LUTs available.

This napkinCAD sketch shows how [SM6VFZ] implemented the boost regulator in the ATtiny214. The AND gate is formed using one of the CCL LUT’s. The first “timer 1” on the left, connected to one input of the AND gate, is free running and set at 33 kHz. The analog comparator compares the boosted output voltage against an internally generated reference voltage derived from the DAC. The output of the comparator then “gates” timer 1 signal to trigger the second “timer 2” — which is a mono-shot timer set to max out at 15 us. This makes sure there is enough time left for the inductor to completely release its energy before the next cycle starts. You can check out the code that [SM6VFZ] used to built this prototype, and his generous amounts of commenting makes it easy to figure out how it works.

Based on this design, the prototype that he built delivers 12 V at about 200 mA with an 85% efficiency, which compares pretty well against regular switching regulators. Keep in mind that this is more of a proof-of-concept (that actually works), and there is a lot of scope for improvement in terms of noise, efficiency and other parameters, so everyone’s comments are welcome.

In an earlier blog post, we looked at how ATmegas with Programmable Logic came about with this feature that is usually found in PIC micro-controllers, thanks to Microchip’s acquisition of Atmel a few years back. But we haven’t seen any practical example of the CCL peripheral in an Atmel chip up until now.

New Part Day: ATMegas With Programmable Logic

Since Microchip acquired Atmel, the fields of battle have fallen silent. The Crusaders have returned home, or have been driven into the sea. The great microcontroller holy war is over.

As with any acquisition, there is bound to be some crossover between two product lines. Both Atmel’s AVR platform and Microchip’s PICs have their adherents, and now we’re beginning to see some crossover in the weird and wonderful circuitry and design that goes into your favorite microcontroller, whatever that might be. The newest part from Microchip is an ATMega with a feature usually found in PICs. This is a Core Independent Peripheral. What is it? Well, it’s kinda like a CPLD stuck in a chip, and it’s going to be in the new Arduino board.

The ATMega4809 is the latest in a long line of ATMegas, and has the features you would usually expect as the latest 8-bit AVR. It runs at 20MHz, has 48 K of Flash, 6 K of SRAM, and comes in a 48-pin QFN and TQFP packages. So far, everything is what you would expect. What’s the new hotness? It’s a Core Independent Peripheral in the form of Configurable Custom Logic (CCL) that offloads simple tasks to hardware instead of mucking around in software.

So, what can you do with Configurable Custom Logic? There’s an application note for that. The CCL is effectively a look-up table with three inputs. These inputs can be connected to I/O pins, driven from the analog comparator, timer, UART, SPI bus, or driven from internal events. The look-up table can be configured as a three-input logic gate, and the output of the gate heads out to the rest of the microcontroller die. Basically, it’s a tiny bit of programmable glue logic. In the application note, Microchip provided an example of debouncing a switch using the CCL. It’s a simple enough example, and it’ll work, but there are a whole host of opportunities and possibilities here.

Additionally, the ATMega4809, “has been selected to be the on-board microcontroller of a next-generation Arduino board” according to the press release I received. We’re looking forward to that new hardware, and of course a few libraries that make use of this tiny bit of custom programmable logic.

Nixie Plasma Ball

plasma_ball_pic5

This one came out over a year ago and we missed it. [Daqq] has made a plasma ball out of a nixie tube.  All that was required was the transformer from a cold cathode meant for computers and a nixie tube. He did have to do a tiny bit of modification to the power supply, which you can see on the project page. This isn’t the most useful project, since you can’t really see much of the plasma, but it is really cool nonetheless. We think this would make a really neat button. You can see a video of it in action after the break.

Continue reading “Nixie Plasma Ball”