PIC microcontroller pin stopped working

faulthi-tech-compilerpic

I am just learning how to use microcontrollers, and I have built simple circuits using the PIC16F877A. I have built a simple circuit that flashes the pins on PORTB on and off by setting PORTB to 0xFF in HI-TECH c.

The problem that I am facing is that despite doing this, the pin RB0 will not turn on or off after having had it work previously. The weird thing is that it originally had not worked, than it had begun working and now it won't work again. I was wondering what possible problems might be causing the issue. I am tempted to just order another PIC and try again, but I was just wondering if there was anything else I should try first.

Here is my program

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

int main()
{
    PORTB = 0x00;
    TRISB = 0x00;

    while(1)
    {
        for(int i = 0; i<1000; i++)
            __delay_ms(1);

        PORTB = 0xFF;

        for(int i = 0; i<1000; i++)
            __delay_ms(1);

        PORTB = 0x00;
    }
}

Best Answer

The PIC16F877A pins can source or sink no more than 25 mA.

It may be possible to damage the device by drawing excess current from an IO pin. for example by driving a LED without a current limiting resistor.