Take Dwayne's code and just add some defines to the top of it... we're making assumptions that you know how to configure your PIC... this selection takes that assumption away... so you don't need an xtal, and you don't need to worry about MCLR either- just apply volts and it WILL run.
Code:
'
' PIC Defines
' -----------
@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
' System Clock Options (Internal)
@ DEVICE pic12F675, WDT_ON
' Watchdog Timer
@ DEVICE pic12F675, PWRT_ON
' Power-On Timer
@ DEVICE pic12F675, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic12F675, BOD_ON
' Brown-Out Detect
@ DEVICE pic12F675, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic12F675, PROTECT_OFF
' Program Code Protection
'
' Dwayne's Blinky Bit
' -------------------
'
' Hardware Defines
' -----------------
LED var GPIO.1 ' This is the pin the blinks a light.
'
' PIC Initialisation
' ------------------
ANSEL=0
CMCON=%00000111
TRISIO=%00001000
'
' Main Program Loop
' -----------------
Loop:
High LED
Pause 1000
Low LED
Pause 1000
goto Loop
End
Don't forget to connect your LED via (a Resistor - say 330R) to pin GP1 (that's physical pin 6 of the PIC), BUT make sure you got the LED the right way around...
Either...
1. LED connected to Vdd (+5v)
Connect LED's Anode to Vdd and Kathode to the PIC (Resistor can be anywhere in series).
2. LED connected to Vss (0v)
Connect LED's Anode to the PIC, and the Kathode to Vss (again, the Resistor can be anywhere in series).
Bookmarks