I am new, and need help
Posted: Sat Aug 04, 2018 2:10 pm
I am new to microcontrollers and programming for embedded systems. Just got a gift of a PICKit3 and decided to test it out. The ode compiles, but the microcontroller doesn't do what I expected it to do(count from 1-31, in binary and output it to connected LEDs. There is an external 6MHz Crystal Oscillator, and the MCLR pin is pulled high through a 10K resistor.
Here's the code:
Here's the code:
- Code: Select all
#include <xc.h>
#pragma config FOSC = HS
#pragma config WDTE = OFF
#pragma config PWRTE = OFF
#pragma config MCLRE = ON
#pragma config BOREN = OFF
#pragma config LVP = OFF
#pragma config CPD = OFF
#pragma config CP = OFF
#define _XTAL_FREQ 6000000
void main(void)
{
TRISA = 0xE0;
unsigned char i;
i = 0;
for(i = 0; i <= 31; i++)
{
PORTA = i;
__delay_ms(100);
if(i=31)i=0;
}
}