#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---*/