Overclocked
Member
Hi Everyone!
Ive been using Some form of PIC basic for years (Swordfish SE, Great Cow Basic). One of the reasons was because it was easy to use, easy to read and most of the time there are plentiful libraries (like ADC,LCD,etc). However, with my latest project, even though its simple, I realized I could use it as a great learning experience and teach myself C.
Hopefully Im on the right path. I chose MPLAB X and XC8 complier to go along with it. I went with XC8 because..well its free! (Im open to others-I know of another by mikroC). However, I cant figure out how to tell the compiler the Frequency I want, Or how to set OSCCON.
PIC used: PIC12F1840. Why not something bigger? Well because my application doesnt need anything more than 8 pins (Its for a smart charger)
Now in BASIC compliers, Its pretty easy, something like:
But in C, I cant figure out how to do this. Ive searched around the web to no Avail. Ive been studying C, but I havent come across this "int main" function yet. Most of the time I see void main
(theres not much here, Im just putting it here for completeness)
Also, Is C the same everywhere? This doesnt seem to be the case between different compilers and how they set up the chips
Ive been using Some form of PIC basic for years (Swordfish SE, Great Cow Basic). One of the reasons was because it was easy to use, easy to read and most of the time there are plentiful libraries (like ADC,LCD,etc). However, with my latest project, even though its simple, I realized I could use it as a great learning experience and teach myself C.
Hopefully Im on the right path. I chose MPLAB X and XC8 complier to go along with it. I went with XC8 because..well its free! (Im open to others-I know of another by mikroC). However, I cant figure out how to tell the compiler the Frequency I want, Or how to set OSCCON.
PIC used: PIC12F1840. Why not something bigger? Well because my application doesnt need anything more than 8 pins (Its for a smart charger)
Now in BASIC compliers, Its pretty easy, something like:
Code:
Clock = 8
Config OSC = INTIO67
But in C, I cant figure out how to do this. Ive searched around the web to no Avail. Ive been studying C, but I havent come across this "int main" function yet. Most of the time I see void main
Code:
#pragma config FOSC = INTOSC, CLKOUTEN = ON, PLLEN = OFF, WDTE = OFF, LVP = OFF
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
return (EXIT_SUCCESS);
}
(theres not much here, Im just putting it here for completeness)
Also, Is C the same everywhere? This doesnt seem to be the case between different compilers and how they set up the chips
Last edited: