So for a project, I’m using a PIC10F due to their very small size (in a SOT23-6, wow) and low cost. They don’t have interrupt support, but they do have a timer, watchdog timer and a comparator. You can do some fairly funky things with them. However, I’m opting to use assembly for this project since it’s probably going to be simpler this way, as the stuff I need to do is very timing critical (reading sensors without interrupts = lots of polling). Also I think I can squeeze the size of the program down better than a C compiler might do.
But I ran into a roadblock. There are no documentations of assembly code listings for the PIC10F, and very few resources online. So here’s a little snippet for you, which blinks an LED on pin GP2:
list p=10F222 ; list directive to define processor
#include
; processor specific variable definitions
#define LightOn bsf GPIO,2 ; turn drive output on
#define LightOff bcf GPIO,2 ; turn drive output off
;**********************************************************************
ORG 0x1FF ; processor reset vector
ORG 0x000 ; coding begins here
cblock 0x18 ; this is where we declare what to call user memory locations
DelayTime:3 ; reserve 3 locations for delay counters
endc
goto Init
Start:
clrwdt
LightOn
call Delay
LightOff
goto Start
Init:
movwf OSCCAL ; load factory osccal value at start-up
bcf OSCCAL,0 ; do NOT output osc/4 on GP2 (IR sensor input)
movlw b'00000000' ; set all GPIO low at startup
movwf GPIO ; load port latches
movlw b'00000000' ; All GPIO pins are outputs
tris GPIO ; set I/O directions
movlw b'11011000' ; wake-up on pin change disabled, weak pull-ups off
; Timer0 clock select on GP2 internal
option ; write to OPTION_REG
; clear all user RAM/variables on boot
movlw 0x10 ; initialize pointer
movwf FSR ; to RAM start
goto Start
Delay ;
movlw D'2' ; 2 = a delay period of approximately 500mS
Delay2 ;
movwf DelayTime ; pre-load W & enter at Delay2 for different delays
movlw D'232' ;
movwf DelayTime+1 ;
movlw D'255' ;
movwf DelayTime+2 ;
Dloop
clrwdt ; 1
decfsz DelayTime+2,f ; 1
goto $-2 ; 2/1
decfsz DelayTime+1,f ; 1
goto $-4 ; 2/1
decfsz DelayTime,f ; 1
goto $-6 ; 2/1
retlw 0 ; 2
end
Delay routine and general structure is shamelessly stolen from Bruce on PICbasic.co.uk.
Hopefully, someone will find this useful



