Hi, ive been trying to run a very simple routine on a PIC 16f877A together with a PICDEM 2 plus demoboard. the program is a simple blinking LED type routine. the program compiles fine and i can debug it using the sim in MPLAB, however when i run it on the demo board nothing happens at all. thinking that this could relate to the oscillator ive tryed using the different oscillators on the board (RC and canned oscillator, remembering to change the config word accordingly). no luck though. ive tryed replacing the device to check if it was a bad chip. still no luck. ive never used external oscillators before and ive been unable to find a thread that deals with this particular setup. IM using MPLAB PICC (hi-tech lite) with an ICD 3 programmer. I havent got a scope so im unable to check the oscillators but since ive tryed them both oscillator sources on the board it seem unlikely to be the issue.
i hope somone can give me an idea to fix this as im slowly loosing my mind over this
i hope somone can give me an idea to fix this as im slowly loosing my mind over this
Code:
#include <HTC.h>
/*
#########################
# Program to blink LEDs #
#########################
*/
__CONFIG(FOSC_XT & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);
/*We need to include the header file “pic.h” which contains all the device related information*/
#include <pic.h>
/*_XTAL_FREQ is used in delay functions, im using a 4 MHZ canned oscillator*/
#define _XTAL_FREQ 4000000
void main(void)
{
/*PORT B is given an initial value of all high, i.e. now all the LEDs will glow*/
PORTB = 0b00001111;
/*TRISB is used to set the direction of PORT B, 0 means PORT B will function as Output Port and 1 means Input Port*/
TRISB = 0b00000000;
/*Infinite loop is used to keep the LEDs blinking*/
while(1)
{
/*The __delay_ms(1000) is used to create a delay of 1000ms. This is a special function defined in “pic.h”. Alternatively one could write a empty loop to create a delay.*/
__delay_ms(1000);
PORTB = 0b00000000; //All LEDs Off
__delay_ms(1000);
PORTB = 0b00001111; //All LEDs On
}
}
/*---END---*/
Last edited by a moderator: