bj2010
Newbie level 6
Hi,
I am using PIC (16F628a)microcontroller for the first time. I was trying to make an LED blink. The C programme which I was using is pasted below. The LED is connected to pin 6(RB0) . After programming the chip the LED is glowing, but its not blinking. I tried changing the delay, but no difference.
I am using MPLAB IDE and Hi-tech compiler. when tried using the simulator (MPLAB SIM)available in MPLAB it seems like once it enters the delay function the control is lost . In the for loop,when the number 10000 is replaced with 100 I can see that the for loop is executed only twice and the control (PC)returned to the main function, and in the simulator logic trace I can see a square wave.
Pls help !!!
Regards
Bipin
#include <pic.h>
#include <HTC.h>
__CONFIG(0x3FF0);
void delay(void);
void main(void) {
TRISB = 0x00;
while (1) {
PORTB = 0b00000001;
delay();
PORTB = 0b00000000;
delay();
}
}
void delay(void) {
unsigned int i;
for (i=0; i<10000; i ++)
;
}
I am using PIC (16F628a)microcontroller for the first time. I was trying to make an LED blink. The C programme which I was using is pasted below. The LED is connected to pin 6(RB0) . After programming the chip the LED is glowing, but its not blinking. I tried changing the delay, but no difference.
I am using MPLAB IDE and Hi-tech compiler. when tried using the simulator (MPLAB SIM)available in MPLAB it seems like once it enters the delay function the control is lost . In the for loop,when the number 10000 is replaced with 100 I can see that the for loop is executed only twice and the control (PC)returned to the main function, and in the simulator logic trace I can see a square wave.
Pls help !!!
Regards
Bipin
#include <pic.h>
#include <HTC.h>
__CONFIG(0x3FF0);
void delay(void);
void main(void) {
TRISB = 0x00;
while (1) {
PORTB = 0b00000001;
delay();
PORTB = 0b00000000;
delay();
}
}
void delay(void) {
unsigned int i;
for (i=0; i<10000; i ++)
;
}