By Abdul Rehman
LED Blink Program is a hello world program of microcontroller world. It not only gives us the idea of how to use the GPIOs of the microcontroller but also makes us sure that our development environment is stable and ready to use. PIC16F676 microcontroller is a 14 pin microcontroller that is very much suitable for many small IO related applications. We are going to create a first Hello world program for PIC16F676. We also call this PIC16F676 LED blink program. For the sake of simplicity and detailed explanation, we are going to use the PIC Hi-Tech Compiler with MPLAB IDE. We may also use the other compilers like PIC CCS or MikroC Pro for PIC, but we rather chose PIC Hi-Tech compiler to get a good underneath knowledge rather than just using the built-in libraries.
Before we jump into the coding section of the PIC16F676 microcontroller, we need to understand the basic introduction of this 16F676 microcontroller. For that, you need to look for the datasheet for the PIC16F676 microcontroller. Which says that it is a 14-Pin, Flash-Based 8-Bit CMOS Microcontroller. Other main features of the microcontroller are as follows
Here are the peripherally related features of the PIC16F676 Microcontroller according to the datasheet of the PIC16F676 microcontroller from the Microchip manufacturers.
Here is the complete final code for the LED Blinking attached to the Bit_0 of the PORTC.
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG( 0x3FFC);
void main()
{
//MAKE PORTA & PORTC OUTPUT
TRISA=0x00;
TRISC=0x00;
//---------------------------------
ANSEL = 0b00000000;//MAKE ALL ANALOG PINS AS DIGITAL OUT
CMCON=0x07;//comparator off
ADCON1=0x10;//Fosc/8 speed
while(1)
{
PORTC |= (1<<1);
__delay_ms(1000);
PORTC &= ~(1<<1);
__delay_ms(1000);
}
}
Code language: PHP (php)
20 November 2022
13 November 2022
07 September 2022
27 July 2022
28 February 2022
FYP Solutions Powered By Impressive Business WordPress Theme