Hi Guys,
I'm trying to get a blink program to work on MPLAB X with a XC8 compiler, I'm coding in C. My chip is a 12F508.
Coming from programming arduinos, this is quite a steep learning curve and I've found pretty much every tutorial I can find to be a little different. The two primary sources I am using are the closest I can find to the chip I have, the one on youtube:
And the other a Gooligum tutorial. I have had more progress trying to copy the code in the youtube video, it looks like this:
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
#include "header.h"
#pragma config OSC = IntRC // Oscillator Selection bits (internal RC oscillator)
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config CP = OFF // Code Protection bit (Code protection off)
#pragma config MCLRE = ON // GP3/MCLR Pin Function Select bit (GP3/MCLR pin function is MCLR)
#define _XTAL_FREQ 4000000
void main(void) {
TRISGPIO = 1;
while(1)
{
GPIObits.GP0 = 1;
__delay_ms(500);
GPIObits.GP0 = 0;
__delay_ms(500);
}
}
When using this code the LED, which is simply connected via a resistor from source to the pin, lights up but does not turn off.
Gooligum has code that is different, it goes more like this:
void main(void) {
TRIS = 0b111101;
for(;
{
GPIO = 0b000010;
__delay_ms(500);
GPIO = 0;
__delay_ms(500);
}
}
The LED does not light up with the Gooligum code.
After I created the project as a main project and added a C file as a source I also added a header file, which it created and I referenced without altering it. I was trying to copy the youtube video.
I seem to have not problem using a pickit 3 to interact with the chip, everything is plugged in the right place and I get no errors. I've been trying for hours to learn my way out of being stuck but I am still stuck. I think the problem with with my code or my IDE settings, I've attached images of my setup, I would greatly appreciate it if you could check it over.
Please help me, haha