After many hours of scratching my head and looking things up and asking questions here, I finally have a decent "starting template" for the PIC 10F222, which I hope can help others so they can cut to the chase. Thanks again for the help, guys.
Code:
'****************************************************************
'************** 10F222 Template *********************************
'****************************************************************
'
' *** IMPORTANT NOTES ***
'
' The PIC10F parts require a special programming adapter,
' even when using the 8-pin DIP package. They won't work in the standard
' adapters like the 8-40 pin or the 8/18/20 pin. See below for pin assignments.
'
' Also, the 10F222 only has **3 BYTES** of variable space after PICBASIC
' assigns its own ones for internal use.
'
'****************************************************************
'
' Major Register Considerations
' OSC is selected in the CONFIGURATION WORD (4 or 8MHz)
' be sure to DEFINE OSC x where x is the frequency number
' ADCON0 - must be properly set before I/O (p.30) - POR assigns ANALOG
' use ADCON0=0 if all is digital I/O
' ***DO NOT ERASE OR OVERWRITE $1FF, it's the OSCCAL value***
' OPTION_REG.7=ACTIVE LOW Wakeup On Change for GPIO.0,1,3 (all or nothing)
' -this is set to 1 (off) on POR
' OPTION_REG.6=ACTIVE LOW Weak Pullups on GPIO.0,1,3 (all or nothing)
' -this is set to 1 (off) on POR
' OPTION_REG.5=0 to allow I/O use of GPIO.2 (POR sets to 1)
' TRISGPIO is the I/O direction setting register, has low nibble only
' GPIO.3 is READ ONLY if configured as I/O
' GPIO.2 has NO Weak Pull-up and NO wake on change
' CONFIG WORD (external to program) - see page 33 of document
' Pinout follows:
'****************************************************
' N/C - 1 8 - GP3/MCLR'/VPP
' VDD(+) - 2 7 - VSS(GND)
' GP2/TOCKI/FOSC/4 - 3 6 - N/C
' GP1/AN1/ICSPCLK - 4 5 - GP0/AN0/ICSPDAT
'****************************************************
'
' set parameters
'
ADCON0=0 'all digital I/O
OPTION_REG.5=0 'allow GPIO.2 use
TRISIO=%1111 'all inputs (GPIO.3 is input only so it's ignored)
DEFINE OSC 8 'set for timing constants etc
DEFINE OSCCAL_1K 1 'copy the calibration value from $1FF to the OSCCAL register
'*******************************************************
'
' variables and constants **ONLY 3 BYTES AVAILABLE FOR VARIABLES**
'
'*******************************************************
'
' begin program
PAUSE 1000 'window for ICSP after power-up *optional
TRISIO=%0000 'change to your own settings and continue with program below *optional
end
Bookmarks