Iawia
Member
Hey all,
I am trying to get my LED to blink. I have been learning to use the pic microcontrollers. I am trying to use c language. I am using the xc8 compiler. The program builds successfully, I select the programmer (Pic2 Kit), program the chip, and release it.
The LED stays unlit for 10 seconds and then turns on. It is suppose to blink! can anyone see any errors or improper setup, coding, etc? Please help.
I am trying to get my LED to blink. I have been learning to use the pic microcontrollers. I am trying to use c language. I am using the xc8 compiler. The program builds successfully, I select the programmer (Pic2 Kit), program the chip, and release it.
The LED stays unlit for 10 seconds and then turns on. It is suppose to blink! can anyone see any errors or improper setup, coding, etc? Please help.
Code:
#include <xc.h>
__CONFIG(MCLRE_OFF & CP_OFF & WDTE_OFF & OSC_IntRC);
//Master clear off, code protection off, watch dog timer off
#define _XTAL_FREQ 4000000 // 4 Mhz
//To reference speed with __delay_ms() or __delay_us()
void main(){
TRIS = 0b111101; //set GP1 as an OUTPUT
for(;;){ //loop forever
GPIO = 0b000010; // GP1 HIGH
__delay_ms(500); // 1/2 s delay
GPIO = 0b000000; // GP1 LOW
__delay_ms(500); // 1/2 s delay
}
}