In this article I’ll show you how to program Microchip PIC microcontrollers using HI-TECH PICC compiler and basic PIC development board. The board consists of PIC16F876A
//—————————————————————————————-
#include <pic.h>
__CONFIG(HS & UNPROTECT); // Setup the configuration word
#define _XTAL_FREQ 2000000 // Define oscillator as 20Mhz
void main(void)
{
TRISB=0x00; // All 8 bits of POTRB will be used as outputs
for(;;)
{
PORTB = PORTB++; //Increase PORTB count
__delay_ms(1000);
}
}
//—————————————————————————————–
Design schematic and PICKIT3 programmer connections are shown in the next figure. Make sure to connect PGC and PGD lines correctly otherwise your microcontroller will not be recognized by MPLAB. Header and C source files can be downloaded here.