Hi Mike,
Welcome to the forum. This series PIC has a 4MHz internal oscillator, an analog comparator,
and a host of other goodies you'll need the data sheet to get familiar with.
CMCON = 7 will disable the onboard comparator so you can use associated pins as digital I/O.
If you plan to use the internal oscillator, then you'll want to enable it using the INTRC_OSC
option in config. Use this below to get started. Just place the next line at the very beginning
of your program.
Code:
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT,WDT_OFF,PWRT_ON,MCLR_OFF,BOD_ON,CPD_OFF,PROTECT_OFF
DEFINE OSCCAL_1K 1' Set OSCCAL for 1k ' <-- this loads the factory calibration value for the int osc
DEFINE OSCCAL_1K 1 is in your PBP manual.
If you're curious about what all these config options are, just look in the data sheet under
the Special Features of the CPU section. You might also want to use the search feature
here to turn up even more info, but this will get you up & going for now.
I/O-pins on these are refered to as GPIO. GPIO.0, GPIO.1, etc,,.
The TRIS register is called TRISIO. TRISIO = %xxx x being 1's or 0's for inputs or outputs.
Now try something simple just to get familiar with the 12F part;
Code:
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT,WDT_OFF,PWRT_ON,MCLR_OFF,BOD_ON,CPD_OFF,PROTECT_OFF
DEFINE OSCCAL_1K 1
CMCON = 7
loop:
High GPIO.0 ' Turn on LED connected to 0
Pause 500 ' Delay for .5 seconds
Low GPIO.0 ' Turn off LED connected to 0
Pause 500 ' Delay for .5 seconds
GoTo loop ' Go back to loop and blink LED forever
TIP: Just in case, you might want to first read a new 12F629 with your device programmer,
and jot down the factory calibration value. If your programmer erases this, you'll need to
know what it was.
There should be several threads around here with info on finding the proper value again, so
I won't re-type it all again here.
Use the search feature here to look around for more on using the 12F series. If you have
more questions after reading any of them, then fire away.
MeLabs has a few examples for the LAB-X4 board you might also want to have a look at;
http://www.microengineeringlabs.com/doclist.htm#X4
P.S. The 12F629 is not a 12-bit core device. It's 14-bit, so pretty much any PBP command
should work just fine with it. As long as it's not a hardware command for a peripheral that
doesn't exist on the PIC itself.
Bookmarks