PIC Microcontoller Input / Output LED Methods

Tony Nixon [sales at picnpoke.com] of ICmicro's says:

This program will flash a LED from port pin RC4
RC4 -> Led Anode
Led Cathode -> 1K res
1K res -> ground

;
        Title "LED flasher."
;
        list P = 16F877
;
        include "P16f877.inc"  ; use definition file for 16F877
;
; --------------------
; USER RAM DEFINITIONS
; --------------------
;
        CBLOCK 0x20   ; RAM starts at address 20h
NaHi
NaLo
NbHi
NbLo
        ENDC
;
        org 0x0000      ; start address = 0000h

; INITIALISE PORTS
; binary used to see individual pin level

        movlw b'00000000'       ; all port pins = low
        movwf PORTA
        movlw b'00000000'
        movwf PORTB
        movlw b'00000000'
        movwf PORTC
        movlw b'00000000'
        movwf PORTD
        movlw b'00000000'
        movwf PORTE

        bsf STATUS,RP0  ; set RAM Page 1 for TRIS registers

; INITIALISE PORTS
; binary used to see individual pin IO status

        movlw b'00000000'       ; all IO pins = outputs
        movwf TRISA
        movlw b'00000000'
        movwf TRISB
        movlw b'00000000'
        movwf TRISC
        movlw b'00000000'
        movwf TRISD
        movlw b'00000000'
        movwf TRISE

        movlw b'00000110'       ; all analog pins = digital
        movwf ADCON1

        bcf STATUS,RP0  ; back to RAM page 0

; LED FLASH LOOP

Loop    bsf PORTC,4     ; RC4 = high = led on
        call Delay

        bcf PORTC,4     ; RC4 = low = led off
        call Delay
        goto Loop

; 1/2 SEC DELAY SUBROUTINE WITH 4MHz CLOCK

Delay   movlw 01h
        movwf NbHi
        movlw 03h
        movwf NbLo
        movlw 8Ah
        movwf NaHi
        movlw 5Bh
        movwf NaLo

DeLoop0 decfsz NaLo,F
        goto DeLoop0
        decfsz NaHi,F
        goto DeLoop0
        decfsz NbLo,F
        goto DeLoop0
        decfsz NbHi,F
        goto DeLoop0
        ;
        return

        end

Questions:

Comments:

Interested: