Introduction

Author: Gheorghe Turcan, Microchip Technology Inc.

Using logic gates, systems can make decisions based on criteria without Central Processing Unit (CPU) intervention. Traditionally, these logic gates are manually implemented as external components. However, the PIC® microcontrollers (MCUs) offer this as a built-in functionality.

The Configurable Logic Cell (CLC) has a variety of basic gates, as well as sequential logic options that can be customized to create the logic specific to many applications. Using these logic gates, the CLC gives the ability of combining signals to make a new custom signal without running code to execute it. The CLC also offers flexible input selection (internal, external signals) and configurable output for internal or external use with the help of the Peripheral Pin Select (PPS).

This technical brief explains the concepts of the CLC and its implementation in the PIC18 family of microcontrollers with the following use cases:

  • Using Basic Logic Gates:

    This example shows how to use the CLC to implement the basic logic functions AND, OR and XOR of two internally generated signals. The outputs of the CLCs are connected to I/O pins.

  • Using CLCs to Create a Data Signal Modulator:

    This example shows how to use the CLC in both J-K flip-flop and AND-OR configurations to obtain a DSM function (multiple frequency carrier signal).

  • Using the CLC to Create an LED Dimming Effect:

    This example shows how to use the CLC in an SR Latch configuration to obtain a PWM signal that changes duty cycle without code addition. The change in duty cycle can be used to generate the effect of an LED dimming or increasing brightness instead of blinking.

Note: For each use case, there are two different implementations that have the same functionalities: one code generated with MPLAB® Code Configurator (MCC) and one bare metal code. The MCC generated code offers hardware abstraction layers that ease the use of the code across different devices from the same family. The bare metal code is easier to follow and allows a fast ramp-up on the use case associated code.