I want to blink led with pic16f628a using pickit2 I generated the hex file and successfully write it, according to code, RB are input, but when I put led between RB0,1,2,3.. and ground it turn on. all the pin turn on the led, I'm using 5 volt output
code :
#include
// Config word
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF);
// Define LED pin
#define LED RA1
#define _XTAL_FREQ 8000000
void main()
{
TRISA1 = 0; // Make RA1 pin output
TRISB = 1;
LED = 0; // Make RA1 low
while(1)
{
__delay_ms(500); // Half sec delay
LED = 0; // LED off
__delay_ms(500); // Half sec delay
LED = 1; // LED on
}
}
scheme :
Answer
You're setting A0 to be an output, then you're blinking A1. Which is it? A0 or A1? Make your mind up, and then make them both the same.
Another thing I notice on your schematic. You're setting the oscillator to be HS, yet I'm not seeing ant crystal or loading caps on your schematic. Did you just omit them from that drawing, or do they truly not exist?
The same goes for the (missing) obligatory decoupling capacitor on the power pin.
No comments:
Post a Comment