Friday, 7 August 2015

pic - pic16f628a successfully programmed but not working



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 : enter image description here


enter image description here



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

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...