Electronic – Basic PIC circuit is not working

microcontrollerpic

I have just begun in the world of microcontrollers, and the first microcontroller. I chose to work with was the PIC from Microchip. The PIC I am using is the PIC16F877A. I am using MPLAB IDE and HI-TECH C. I am trying to make an extremely simple program that turns on an LED. This is the code I am using:

#include<htc.h>
#define _XTAL_FREQ 8000000
__CONFIG(UNPROTECT & PWRTDIS & WDTDIS & HS & LVPDIS); 

int main()
{
    TRISB0 = 0;
    RB0 = 1;
    while(1);
}

When I hook up the PIC to my circuit the LED does not turn on. Here is my circuit diagram and a picture of my circuit:

enter image description here

enter image description here

A few other notes about my circuit:

  • I am using a 9 volt battery hooked up to a 7805 regulator for the power supply.
  • I have measured the voltage coming from pin RB0 with a multimeter and it measures 0.0 V.
  • If there is no problem with my circuit I could have programmed the chip wrong.
  • My capacitors hooked up with my crystal are 22 pf, not 22 µf as in the schematic.
  • I have put 100 µf capacitors between pins 11 and 12 and between 31 and 32.

Best Answer

As it's impossible to put code in comments, I'll put my suggestion for code that sets the Config bits correctly here. The issue is I don't have this compiler so I cannot be certain of the names (LVPDIS as opposed to, say, LVP_OFF in assembly) but if I'm wrong, someone could comment(?)

#include <htc.h>

#define _XTAL_FREQ 8000000

__CONFIG(UNPROTECT & PWRTDIS & WDTDIS & HS & LVPDIS);

int main()
{
    TRISB0 = 0;
    RB0 = 1;
    while(1);
}