Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16f877a,,

Status
Not open for further replies.

wAnted

New Member
my 16F877a can't provide output..


__________________________________________________ __
#include <pic.h>
#include "delay.c"
#include "adc.c"

//CONFIG bits
__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);


unsigned char display = 0;

void init_LEDS(void)
{

TRISB = 0x00;
PORTB = 0x00; //8 LEDS at PORTB

}


void main()
{
unsigned int adc_val; //hold adc value

init_LEDS();
init_ADC();


PORTB = 0X00;
start:
adc_val = read_ADC();
DelayMs(40);
if(adc_val < 573) // 0 - 1V
{
RB6 = 0;
RB5 = 1;
}

if(adc_val >=573 && adc_val <= 860) // 2.8-4.20V
{
RB6 = 1;
RB5 = 0;
}

if(adc_val >=880) //4.3V-above
{
RB6 = 1;
RB5 = 1;
}
DelayMs(20);


goto start;
}
__________________________________________________


when I tried to load this to my friends PIC it works properly but in my PIC, it wont provide an output? whats wrong?
 
It is probably because your pic isn't running.

Possible causes,
No/wrong crystal or no/wrong capacitors.
MCLR not tied high.
RB3 not tied high as LVP not turned off.
No power.
Pic not programmed.
Etc.

Mike.
 
try erasing the pic, when done check the buffer of the pic if it is blank all 0xff then try to fill the buffer with some hex read it again if it is there as u put it, this will confirm if you are able to program the pic
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top