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.

Question regarding PIC16F877

Status
Not open for further replies.

praveen_kw

New Member
Im using a PIC16F877 development board which comes with 34 pins that can be connected to a bus cable. i found a simple program online that makes LEDS blink. the LEDS light up but they dont blink. Im using PORTB pins for the LEDS.

anyone knows why the LEDS wont blink??
 
praveen_kw said:
Im using a PIC16F877 development board which comes with 34 pins that can be connected to a bus cable. i found a simple program online that makes LEDS blink. the LEDS light up but they dont blink. Im using PORTB pins for the LEDS.

anyone knows why the LEDS wont blink??
What delay do you have between On & OFF pulses?
Could you post your CODE and scheme here?
 
#include <pic1687x.h>

/*
* Demo program
*
* Flashes LEDs on Port B, responds to switch press
* on RA1. Usable on PICDEM board.
*
* Copyright (C)1997 HI-TECH Software.
* Freely distributable.
*/

#define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit))
#define RC 0x3FFF
#define WDTEN 0x3FFF
#define PWRTDIS 0x3FFF
#define BOREN 0x3FFF
#define LVPEN 0x3FFF
#define WRTEN 0x3FFF
#define WRTEN 0x3FFF
#define DEBUGEN 0x37FF
#define UNPROTECT 0x3FFF

static bit button @ PORTBIT(PORTB, 1);


main(void)
{
unsigned char i, j;

TRISB = 0; /* all bits output */
j = 0;
for(;;) {
PORTB = 0x00; /* turn all on */
for(i = 1000 ; --i ;)
continue;
PORTB = ~j; /* output value of j */
for(i = 1000 ; --i ;)
continue;
if(button == 0) /* if switch pressed, increment */
j++;
}
}
 
Try scoping the output pins, I suspect they will be flashing far too fast to see - you don't have anything much in the way of a delay between the port toggling!.

You should use the Delay() command to set a delay, not a crude for/next loop (which is very, very, much too short) - I don't use C, but I'm sure it should have a suitable command.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top