Can’t get PIC 16F876 working.What am I doing wrong

cmicrocontrollerpic

I have been playing around with the PIC16F628 for a while, and now I want to transfer to something that has more pins. Specifically the PIC16F876, but I can't get it working. I just want to turn an LED on/off and nothing ever happens. This is my circuit:

PIC 16F987 circuit

I program my PICs in the mikroC editor and these are the settings:

  • OSCILLATOR: HS
  • WATCHDOG: Disabled
  • POWER-UP TIMER: Disabled
  • FLASH code protection: Disabled
  • Brown-out reset: Enabled
  • Low voltage programming: Disabled
  • Flash program memory write: Enabled
  • In-circuit debug: Disabled

And this is my code:

void main(){
    TRISB = 0x00;
    while(1){
        PORTB = 0b11111111;
        delay_ms(500);
        PORTB = 0b00000000;
        delay_ms(500);
    }
}

And nothing works. I tried with 4.10 and 11 MHz oscillator values
and nothing. What did I do wrong?

Best Answer

With the bypass cap missing, nothing else matters.

I'd also move the LED off of RB6 or RB7 since those are the programming and debugging lines. You won't be able to use either of those pins while debugging. RB5 is a good choice. I don't understand why you'd use a pin multiplexed with anything else when all you're trying to do is test that code is running by seeing a LED blink.

Tie the PGM pin (RB3) to ground.

Don't forget to clear the TRIS bit for the pin you are using.

Test the code in the simulator first. There's no point trying it on hardware until the basic code is working correctly.