p10f200 Blink LED

This has a delay loop to turn on the LED, dely the loop, turn it off and repeat. This gives our eyes a chance to see the LED change state.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "p10f200.inc"
; CONFIG
__CONFIG _WDT_OFF & _CP_OFF & _MCLRE_OFF
ORG 0x0000
INIT
MOVLW ~(1 << T0CS) ; enable GPIO2
OPTION
MOVLW ~(1 << GP2) ; set and GP2 as an output
TRIS GPIO
LOOP
BSF GPIO, GP2 ; set GP2
CALL DELAY ; call DELAY subroutine
BCF GPIO, GP2 ; reset GP2
CALL DELAY ; call DELAY subroutine
GOTO LOOP ; loop forever

DELAY ; start DELAY subroutine here
MOVLW D'162' ; load initial value for the delay
MOVWF 10 ; copy the value to the register 0x10
MOVWF 11 ; copy the value to the register 0x11
DELAY_LOOP ; start delay loop
DECFSZ 10, F ; decrement the register 0x10 and check if not zero
GOTO DELAY_LOOP ; if not then go to the DELAY_LOOP label
DECFSZ 11, F ; else decrement the register 0x11, check if it is not 0
GOTO DELAY_LOOP ; if not then go to the DELAY_LOOP label
RETLW 0 ; else return from the subroutine
END

Charlieplexing LEDs