Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems with delay in PIC16f887

Status
Not open for further replies.

mukundh225

Newbie level 6
Joined
Nov 9, 2010
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,427
I am trying to switch my Port D outputs by a time of 1 sec. below is the code that I am using. Only Rd0, Rd1, Rd2 glow. after Rd2 it switches to Rd0 and it keeps looping. I ve set the register for port D properly but still my other 5 LEDS are not glowing.

Also only when I short RB3(pin 36) to gnd , I get this ouput. Without grounding pin 36 I don't get any LED glowing.

Could anyone please give me a reason for the above two problems.


#include<htc.h>
#include<pic16f887.h>
#include<stdio.h>
#include<conio.h>
#ifndef _XTAL_FREQ
// Unless already defined assume 4MHz system frequency
// This definition is required to calibrate __delay_us() and __delay_ms()
#define _XTAL_FREQ 4000000
#fuses INTRC_IO,NOWDT,NOPROTECT,NOCPD,NOBROWNOUT
#endif

void main()
{

OSCCON = 0x67; //calibrate internal oscillator...read about this in data sheet
TRISD = 0x00; //configuring portd as output(page57)
PORTD=0x00;

while(1)
{

//PORTD = 0xFF; //setting all pins of portD as high

PORTD=0X01;
__delay_ms(1000);//1000ms delay

PORTD=0X02;
__delay_ms(1000);//1000ms delay

PORTD=0X04;
__delay_ms(1000);//1000ms delay

PORTD=0X08;
__delay_ms(1000);//1000ms delay

PORTD=0X10;
__delay_ms(1000);//1000ms delay

PORTD=0X20;
__delay_ms(1000);//1000ms delay

PORTD=0X40;
__delay_ms(1000);//1000ms delay

PORTD=0X80;
__delay_ms(1000);//1000ms delay

}

}




Thanks
Mukund
 

The problems seems to be hardware. Check out proper ground
 

I am using MPlab to write my C code and PICKIT2 to load the program in the PIC16f887.




---------- Post added at 17:58 ---------- Previous post was at 17:56 ----------

I am using a DC power supply.
I have connected the +ve terminal to the Vdd pin.
I have connected the -ve terminal to gnd and then connected it to the Vss pin.
The negative terminal of LEDs also are in the gnd of power supply.

Please tell if anything is wrong with this connection....


Thanks
Mukund
 
Last edited:

myb it some like unwanted connection or it not connected...
 

Check out these settings

Reset & reset pin
eccp
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top