please dont rip this site

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:


file: /Techref/microchip/16F877/flashled.htm, 6KB, , updated: 2017/7/3 10:29, local time: 2024/11/5 04:45,
TOP NEW HELP FIND: 
3.147.49.183:LOG IN
©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/Techref/microchip/16F877/flashled.htm"> PIC Microcontoller Input / Ouput Method - Flash a LED from an 16F877</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?