Hi all,
I am very new to microcontrollers but am very excited to learn the fundamentals of them. I have purchased a PICkit1 for just this reason.
I have tried to create a simple blinking LED using a PIC16F684 and PICkit 1 development board from Microchip. However, all I am getting is constant LED luminance (D0 on the PICKit1 demo board) and it does not seem to be pulsing at all.
I have created it in c using the HI-TECH C Compilier.
Does anyone see any problems in my few lines of code here? Basically have a 2ms delay nested inside a for-loop for 128 repetitions. This should give me approximately 2Hz on the output.
#include <htc.h>
#define _XTAL_FREQ 4000000
main(){
int i;
PORTC = 0x00; // PORTC low
CMCON0 = 0x07; // turn off comparators
ANSEL = 0x00; // turn off ADC
TRISC = 0x00; // set as output
while(1 == 1){
PORTC = 0xff; //PORTC set high
for(i = 0; i <= 127; i++){
__delay_ms(2);
CLRWDT();
}
PORTC = 0x00; //PORTC set low
for(i = 0; i <= 127; i++){
__delay_ms(2);
CLRWDT();
}
}
}
Thanks for the help.
I am very new to microcontrollers but am very excited to learn the fundamentals of them. I have purchased a PICkit1 for just this reason.
I have tried to create a simple blinking LED using a PIC16F684 and PICkit 1 development board from Microchip. However, all I am getting is constant LED luminance (D0 on the PICKit1 demo board) and it does not seem to be pulsing at all.
I have created it in c using the HI-TECH C Compilier.
Does anyone see any problems in my few lines of code here? Basically have a 2ms delay nested inside a for-loop for 128 repetitions. This should give me approximately 2Hz on the output.
#include <htc.h>
#define _XTAL_FREQ 4000000
main(){
int i;
PORTC = 0x00; // PORTC low
CMCON0 = 0x07; // turn off comparators
ANSEL = 0x00; // turn off ADC
TRISC = 0x00; // set as output
while(1 == 1){
PORTC = 0xff; //PORTC set high
for(i = 0; i <= 127; i++){
__delay_ms(2);
CLRWDT();
}
PORTC = 0x00; //PORTC set low
for(i = 0; i <= 127; i++){
__delay_ms(2);
CLRWDT();
}
}
}
Thanks for the help.
Last edited: