Electronic – How to program PIC 12F629 internal oscilator in C

cmplabpic

I have some troubles understanding the datasheets when comes to use the internal oscilator in a PIC 12F629, using C (MPLAB X IDE + XC8 compiler). Also I don't have any PICKIT or anything, I use a DIY K150 programmer. I have read that the manufacturer calibration could be erased when I burn the program. So the specific question is: Which would be the code to use the internal oscilator? (__CONFIG ?) Feel free to recommend a burning procedure.
PS: Sorry for the bad english…

Best Answer

In order to choose for internal oscillator in MPLAB X go to window\PIC memory views\configuration bits

in the row of the FOSC choose one of the INTOSC options and any other configuration you would like

press on the "Generate Source Code to Output" button

copy the text you received to the top of the main.c file

If you see the text you copied displayed as errors don't mind it, it is a known bug in MPLAB X

I never worked with pic12f629 using MPLAB X but basically if you don't erase the entire PIC your OSCCAL will be saved. OSCCAL corruption can also happen if your programing fails (e.g. bad connection during programing). if that happend you should use user2320835 advice and use the XC8 linker option

If i were you i would also try to check for the basic examples found on microchip.com, it will be a very good start