please dont rip this site

Setting up a 16F87x

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

        Title "Your Program"
;
        list P = 16F877
;
        include "P16f877.inc"
;
; ------------------
; CONFIGURATION FUSE
; ------------------
;
        __CONFIG _CP_OFF & _WRT_ENABLE_ON & _RC_OSC & _WDT_ON & _PWRTE_OFF &
_BODEN_ON & _LVP_ON & _CPD_OFF & _DEBUG_OFF
;
; CRYSTAL SPEED = 4000000Hz
;
        CBLOCK 0x20

dataL

        ENDC
;
; -------------
; PROGRAM START
; -------------
;
        org 0x0000              ; startup = 0000h
;
Start   movlw 0x00              ; setup ports
        movwf PORTA
        movlw 0x00
        movwf PORTB
        movlw 0x40
        movwf PORTC
        movlw 0x00
        movwf PORTD
        movlw 0x00
        movwf PORTE
        bsf STATUS,RP0          ; RAM Page 1
        movlw 0x00
        movwf TRISA
        movlw 0x00
        movwf TRISB
        movlw 0x80
        movwf TRISC
        movlw 0xFF
        movwf TRISD
        movlw 0xFF
        movwf TRISE
;
; -------------------------
; SET ANALOG/DIGITAL INPUTS
; -------------------------
;
        movlw 0x06              ; all digital
        movwf ADCON1
;
; ------------------------------------
; SET BAUD RATE TO COMMUNICATE WITH PC
; ------------------------------------
; Boot Baud Rate = 19200, No Parity, 1 Stop Bit
;
        movlw 0x0C              ; 19200 baud
        movwf SPBRG
        movlw b'00100100'       ; brgh = high (2)
        movwf TXSTA             ; enable Async Transmission, set brgh
        movlw b'10010000'       ; enable Async Reception
        bcf STATUS,RP0          ; RAM Page 0
        movwf RCSTA
;
; ------------------------------------
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
        clrf dataL
settle  decfsz dataL,F
        goto settle
;
        movf RCREG,W
        movf RCREG,W
        movf RCREG,W            ; flush receive buffer

Loop    call Receive            ; wait for a char
        movwf TXREG             ; echo data back to sender
        goto Loop
;
; ----------------------------
; RECEIVE CHARACTER FROM RS232
; ----------------------------
; This routine does not return until a character is received.
;
Receive btfss PIR1,RCIF         ; (5) check for received data
        goto Receive
;
        movf RCREG,W
        return
;
; ------------------------------------
; WAIT UNTIL RS232 IS FINISHED SENDING
; ------------------------------------
;
TransWt bsf STATUS,RP0
WtHere  btfss TXSTA,TRMT                ; (1) transmission is complete if hi
        goto WtHere
;
        clrf STATUS             ; RAM Page 0
        return
;
;
        end

Questions:

Comments:


file: /Techref/microchip/16f877/setup.htm, 3KB, , updated: 2010/11/16 21:59, local time: 2024/12/27 11:29,
TOP NEW HELP FIND: 
3.133.124.80:LOG IN

 ©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://massmind.org/Techref/microchip/16f877/setup.htm"> Setting up a 16F87x </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?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .