Summary of PIC12F675 microcontroller as Flip Flop
The article describes implementing D-type and JK-type flip flops using a PIC12F675 microcontroller. The D-type flip flop operates as a negative edge triggered device with active low set and reset inputs, utilizing edge-triggered and port change interrupts. The JK flip flop version introduces the ability to select positive or negative clock edge triggering based on the logic level of GPIO5 after reset, a feature not typically found in discrete logic devices.
Parts used in the PIC12F675 Flip Flop Project:
- PIC12F675 microcontroller
- Power supply (appropriate voltage for PIC12F675)
- Input switches or signal sources for data, clock, set, and reset
- Pull-up resistor on GPIO5 (internally provided by PIC12F675 weak pull-up)
- Output indicator devices (e.g., LEDs connected to output pins)
Code to make a 12F675 operate as a D-type or JK-type flip flop
Since I implemented a D type flip flop using the PIC Logic Elements I thought I might go the other way and implement an entire D type flip flop in a single PIC. This uses the edge triggered and port change status interrupts and was an opportunity to have a play with interrupts on the PIC.
As written this code will cause a PIC to function as a negative edge triggered D type flip flop with active low Set and Reset inputs.
‘D’ type flip flop
- Source Code
- Hex (right-click Save As)
- Schematic PNG , PDF
Following the D type flip flop I’ve hacked it round to make a JK flip flop. This implementation has one extra ‘feature’ that a normal discrete logic device doesn’t have. After a reset, port GPIO5 (pin 2) is read and the logic level used to select either a positive or negative clock edge.
GPIO5 = 1, negative edge (GPIO5 uses weak pull-up, so no external resistor is needed)
GPIO5 = 0, positive edge
For more detail: PIC12F675 microcontroller as Flip Flop