How to implement free running counter in PIC16F84A using seven segment display
This post provides the implementation of free running counter ( using c language ) for PIC16F84A micro-controller. This code is written in such a way that, the counter starts from a value of ‘0’ ( displayed on the seven segment ) and then increments this value after every second. So, the seven segment display starts from ‘0’ and then displays ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘A’, ‘b’, ‘C’, ‘d’, ‘E’, and in the end ‘F’. After displaying ‘F’, counter starts from ‘0’ again and this pattern repeats forever.
The code and Proteus simulation is given in the ‘Downloads‘ section at the bottom of this page. It is assumed that you know how to make an LED blink with PIC16F84A micro-controller. If you don’t, then please read this post first.
The following figure shows the circuit of free running counter in Proteus.
A crystal of 20 MHz is used here. You can use any crystal value from 0 to 20MHz with PIC16F84A. As we know that PIC16F84A microcontroller has an architecture which executes an instruction in 4 CPU cycles , hence this 20Mhz crystal makes this PIC16F84A run at 5.0 MIPS (Million of instructions per second).
PORTB is used here to connect PIC16F84A with the seven segment display. RB0 pin is attached with the ‘a’ segment of the seven segment display. Similarly, RB1 pin is connected with ‘b’ segment, RB2 pin is connected with ‘c’ segment and so on.
Common cathode seven segment display is used in this example. You can easily modify this circuit and code for the common anode seven segment display as well.
The following function is used in the code to display values on the seven segment display.
Free running counter code using PIC16F84A was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
Current Project / Post can also be found using:
- seven segment display using pic 16f84A diagram in proteus diagram
- 7 segment display using pic16f84a
- 7 segment with pic16f84a
- interfacing 7 segment display with 16f84a