Makaram
Member
Hey,
writing my first c program for pic 16f84a
got everything working good, heres my code. only one problem... my code loops infinitely regardless of for, when or if loops?!?!?!?!
Using hi-tech
heres my code
#include <pic.h> // pic specific identifiers
# define _XTAL_FREQ 20000000
__CONFIG(0x3ff2); // Config bits
void main(void) // program entry
{
int i = 0;
TRISA = 0x0; // Both ports
TRISB = 0x0; // as outputs
while(i<10) // Loop forever
{
PORTB = 0xff; // All on!!
PORTA = 0xff;
__delay_ms(180); // Wait a while
PORTB = 0x0; // All off!!
PORTA = 0x0;
__delay_ms(180); // Wait a while
i = i+1;
}
} // End!!
and I've tried
#include <pic.h> // pic specific identifiers
# define _XTAL_FREQ 20000000
__CONFIG(0x3ff2); // Config bits
void main(void) // program entry
{
int i
TRISA = 0x0; // Both ports
TRISB = 0x0; // as outputs
for(i=0; i<10; i++) // Loop forever
{
PORTB = 0xff; // All on!!
PORTA = 0xff;
__delay_ms(180); // Wait a while
PORTB = 0x0; // All off!!
PORTA = 0x0;
__delay_ms(180); // Wait a while
}
} // End!!
my LED constantly flashes infinitely. If i change the delays the LED blink time changes as it should but it still continues for ever. this is driving me insane X_X
Please help
thanks,
Matt
writing my first c program for pic 16f84a
got everything working good, heres my code. only one problem... my code loops infinitely regardless of for, when or if loops?!?!?!?!
Using hi-tech
heres my code
#include <pic.h> // pic specific identifiers
# define _XTAL_FREQ 20000000
__CONFIG(0x3ff2); // Config bits
void main(void) // program entry
{
int i = 0;
TRISA = 0x0; // Both ports
TRISB = 0x0; // as outputs
while(i<10) // Loop forever
{
PORTB = 0xff; // All on!!
PORTA = 0xff;
__delay_ms(180); // Wait a while
PORTB = 0x0; // All off!!
PORTA = 0x0;
__delay_ms(180); // Wait a while
i = i+1;
}
} // End!!
and I've tried
#include <pic.h> // pic specific identifiers
# define _XTAL_FREQ 20000000
__CONFIG(0x3ff2); // Config bits
void main(void) // program entry
{
int i
TRISA = 0x0; // Both ports
TRISB = 0x0; // as outputs
for(i=0; i<10; i++) // Loop forever
{
PORTB = 0xff; // All on!!
PORTA = 0xff;
__delay_ms(180); // Wait a while
PORTB = 0x0; // All off!!
PORTA = 0x0;
__delay_ms(180); // Wait a while
}
} // End!!
my LED constantly flashes infinitely. If i change the delays the LED blink time changes as it should but it still continues for ever. this is driving me insane X_X
Please help
thanks,
Matt