Getting Started with Microchip’s Configurable Logic Cells (CLC): Turn Your PIC16 into a 555 Timer

Introduction

Microchip includes Configurable Logic Cells (CLC) in select enhanced PIC16 and PIC18 microcontrollers. This engineering brief demonstrates how to use the PIC’s CLC along with comparators to perform the functions of a 555 timer. This pseudo 555 is an ideal educational application. The Microchip PIC hardware is easily understood when framed with the operating conditions of the famous 555 timer.

The demonstration project as shown in Figure 1 features a Microchip PIC16F17146-I/SS installed on an EV72J15A curiosity evaluation board.

This article is written assuming the reader is familiar with the classic 555 timer and the PIC microcontroller.

Figure 1 The PIC16 curiosity board showing the resistor trio used to establish the 1/3 and 2/3 rail voltage references for the 555 timer.

What is a Microchip Configurable Logic Cell?

The Configurable Logic Cell (CLC) operates like a tiny Field Programmable Gate Array (FPGA). It is integrated on the same semiconductor die as the microcontroller.

For this application, the core 555 digital logic is shown in Figure 2. The red lines show the MPLAB programming:

  • CLCIN0 routed to set the flip flop

  • CLCIN1 routed to reset the flip flop

All other inputs to the primary 4-pin OR gates are grounded. Consequently, there is a direct connection from the inputs (left) to the corresponding flip flop control lines. If you look closely at the logic, you can see the individual ground symbols on the logic gate inputs.

Figure 2: A set/reset flip flop performs the core 555 logic function.

Tech Tip: The flip flop shown in Figure 2 operates independently of the microcontroller’s clock domains. For metastability mitigation, a universal clocked D flip flop with set and reset is available.

Independence is preferred for this pseudo 555 timer or for applications that require continued operation while the CPU is sleeping. Select based on your project’s needs.

What is a Microchip comparator?

Enhanced PIC devices include CPU-independent hardware on the same die as the microcontroller. “Peripherals” such as the featured CLC, op amps, and comparators can simplify circuit design and parts count by moving functionality into the PIC.

The Microchip datasheet comparator is shown in Figure 3. The output signal will be high when the positive input (Vin+) is higher than the negative input (Vin-).

Figure 3: Representative comparator from the Microchip datasheet.

Tech Tip: The gray areas in the Figure 3 (output signal) are a gentle reminder about comparator stability. In this example, the comparator lacks hysteresis and tends to oscillate when the input voltages are close to each other.

We could mitigate this problem using the classic 3-resistor positive feedback circuit. However, for our pseudo 555 circuit we use the comparator output as a trigger signal with wide separation between the 1/3 and 2/3 rail voltages.

How do I program the Microchip CLC?

The project was programmed using MPLAB:

  • The main project structure is shown in Figure 4.

  • The CLC programming is shown in Figure 2.

  • The remainder of the programming involves assigning I/O pins as shown in Figure 5.

In all cases, the blocks are programmed to operate independently with both inputs and outputs routed to individual I/O pins.

Gotchas

The programming was straightforward, but there were a few problem areas:

  • Avoid the LED connected to the EV72J15A’s port RC1. The LED will load down the circuit. For example, I originally routed a comparator input pin to RC1. The LED plus series-connected resistor prevented the capacitor from charging and discharging.

  • The RA0 pin is multiplexed with the debugger’s DBG0 pin. You must disconnect the comparator input to program the microcontroller.

Figure 4: MPLAB project hierarchy for the pseudo 555 timer featuring a CLC and 2 comparators (CMP).

Figure 5: Pin configuration for the PIC PIC16F17146-I/SS.

Performance

Figure 6 demonstrates the operation of the pseudo 555 circuit. Here we see the output (blue) driving the capacitor (orange) via a resistor. The characteristic 555 RC charge and discharge curves can be seen.

Next Steps

I’ll leave it to you to optimize the circuit. For example:

  • Impedance: The capacitor waveform is slightly off from the anticipated 1/3 and 2/3 rail trigger points. Research the impedance of the comparator and then adjust resistor values as necessary.

  • Frequency: Empirically determine the maximum operating frequency. Once this is done, refer to the datasheet and correlate measured performance with specifications.

  • Synchronization: Modify the CLC to include synchronization with the microcontroller’s clock domain. Determine the maximum frequency for the 555 circuit.

  • Analog circuit design: Since the input and output signals are pin accessible, we can add discrete circuitry. For example, the featured PIC16 also has an op amp. We could amplify the signal and then add a low-pass anti-aliasing filter before passing the signal to the PIC’s ADC.

Figure 6: Oscilloscope representation of the PIC-based 555 timer demonstrating 555-timer-like operation.

Parting Thoughts

The best way to learn electronics is to build on what you know. The venerable 555 timer is the perfect reference point. Teachers and textbook authors love the 555 as it crosses analog plus digital circuitry domains combined with good old RC charging mathematics. Almost all have breadboarded the astable (oscillator) circuit at one point in our lives.

On a personal note, I had a hard time visualizing applications for the Microchip CLC. While this 555 is a silly application, it’s a touchstone that allowed me to understand the hardware and opened my eyes to the possibilities.

Best wishes,

APDahlen

Related Articles by this Author

If you enjoyed this article, you may also find these related articles helpful:

About This Author

Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (interwoven). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET-accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians.

Dahlen has returned to his Northern Minnesota home, completing a decades-long journey that began as a search for capacitors. Read his story here.