1
\$\begingroup\$

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;
    }
}
\$\endgroup\$
4
  • \$\begingroup\$ It is customary in English to capitalize "I" when referring to yourself. I have edited your question accordingly. \$\endgroup\$
    – JYelton
    Feb 2, 2014 at 19:40
  • \$\begingroup\$ I suggest you show the smallest program that shows your problem. \$\endgroup\$ Feb 2, 2014 at 19:44
  • \$\begingroup\$ I posted the program im using, \$\endgroup\$ Feb 2, 2014 at 19:45
  • \$\begingroup\$ Are all the other pins of PORTB blinking? In that case you might somehow have zapped B0... \$\endgroup\$ Feb 2, 2014 at 20:23

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I guess that could be my problem \$\endgroup\$ Feb 2, 2014 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.