MezmerizedMonkey
Newbie level 5
- Joined
- Feb 9, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,342
Hi,
It's my first post here and I'm just starting out with MCUs. I managed to get an LED to blink (yay!), however, at an uneven rate when it's programmed for an even one. I've tried everything that came to mind without success. It's a bit frustrating...
I'm running:
MPLAB X v1.51
XC 8 v 1.12 Compiler
PicKit 2 v2.61 IPE with support for:
PicCircuit ICP02v2 Programmer
PIC 16f1847
My code:
As I mentioned, this does work but poorly:
The LED seems to be on for 3/4 of the loop, off for 1/4 and I have no idea why when both delays are set for 1000ms.
Can anyone help me out?
It's my first post here and I'm just starting out with MCUs. I managed to get an LED to blink (yay!), however, at an uneven rate when it's programmed for an even one. I've tried everything that came to mind without success. It's a bit frustrating...
I'm running:
MPLAB X v1.51
XC 8 v 1.12 Compiler
PicKit 2 v2.61 IPE with support for:
PicCircuit ICP02v2 Programmer
PIC 16f1847
My code:
Code:
#include <pic16f1847.h>
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
//Internal clock setting (OSC of 32Mhz/4)
#define _XTAL_FREQ 800000
void main ()
{
TRISA = 0x00; //PORTA as an output
while (1) //infinite loop
{
PORTA = 0x0f; //PORTA high
__delay_ms(1000);
PORTA = 0x00; //PORTA low
__delay_ms(1000);
}
}
As I mentioned, this does work but poorly:
The LED seems to be on for 3/4 of the loop, off for 1/4 and I have no idea why when both delays are set for 1000ms.
Can anyone help me out?