chiark / gitweb /
Clare's first PIC program.
authorceb <ceb>
Wed, 13 Oct 2004 01:30:04 +0000 (01:30 +0000)
committerceb <ceb>
Wed, 13 Oct 2004 01:30:04 +0000 (01:30 +0000)
Observe the flashing LEDs! (hopefully)

cebpic/.cvsignore [new file with mode: 0644]
cebpic/Makefile [new file with mode: 0644]
cebpic/led-flash.asm [new file with mode: 0644]

diff --git a/cebpic/.cvsignore b/cebpic/.cvsignore
new file mode 100644 (file)
index 0000000..b9fbbeb
--- /dev/null
@@ -0,0 +1,3 @@
+*.hex
+*.cod
+*.lst
diff --git a/cebpic/Makefile b/cebpic/Makefile
new file mode 100644 (file)
index 0000000..1e482f4
--- /dev/null
@@ -0,0 +1,8 @@
+TARGETS=       led-flash.hex
+
+include ../pic.make
+
+clean:         pic-clean
+
+%-full.hex:    %.o config.o
+               $(LINK)
diff --git a/cebpic/led-flash.asm b/cebpic/led-flash.asm
new file mode 100644 (file)
index 0000000..ac85f3d
--- /dev/null
@@ -0,0 +1,53 @@
+; pin 21 (per-pic-led, RD2/PSP2/C1IN) states: high H = green, low L = red, float Z = black
+
+        include         /usr/share/gputils/header/p18f458.inc
+
+       code
+start
+; pin initial config
+       bcf     TRISE,4,0       ; turn off PSPMODE (Data Sheet p100/101)
+; timer initial config
+       bcf     T0CON,0,0       ; p107 Timer0 -> 16bit mode     
+       bcf     T0CON,5,0       ; timer0 use internal clock
+       bcf     T0CON,3,0       ; use prescaler
+       bsf     T0CON,2,0       ; }     
+       bsf     T0CON,1,0       ; } prescale value 1:256
+       bsf     T0CON,0,0       ; }
+; actually do stuff
+       call    green
+       call    waiting
+       call    black
+       call    waiting
+       call    red
+       call    waiting
+       call    black
+       call    waiting
+       goto    start
+
+
+green
+       bcf     TRISD,2,0       ; make pin RD2 an output (DS100)
+       bsf     LATD,2,0        ; set pin RD2 H (green)
+       return
+
+black
+       bsf     TRISD,2,0       ; make pin RD2 an input (i.e. set Z, black) (DS100)
+       return
+
+red
+       bcf     TRISD,2,0       ; make pin RD2 an output (DS100)
+       bcf     LATD,2,0        ; set pin RD2 L (red)
+       return
+
+waiting
+       bcf     INTCON,2,0      ; clear timer0 interrupt bit (p109)
+       clrf    TMR0H,0         ; p107 set high bit of timer0 to 0 (buffered, 
+                               ; so only actually set when write to tmr0l occurs)
+       clrf    TMR0L,0         ; set low bit o timer0 - timer now set to 0000h
+loop
+       btfss   INTCON,2,0      ; check whethr tiomer0 interrupt has been set -
+                               ; skip next instruction if so
+       bra     loop
+       return
+
+       end