Switch to full style
PIC Assembly Articles
Post a reply

Writing a Counter to any PORT

Thu May 16, 2013 12:25 am

Writing a counter to a PORT
Code:

TITLE 
"Write Count to Port D"
list p = 16f877
include 
<p16f877.inc>
DELAY_VHI EQU H'30'
DELAY_HI EQU H'31'
DELAY_LO EQU H'32'
COUNT EQU H'33'
ORG H'00'
NOP
GOTO START 

ORG 0x20
START BCF STATUS
,RP0; BANK 0
CLRF PORTD
; INITALIZE PORTC BY CLEARING OUTPUT

DATA LATCHES
BSF STATUS
,RP0; SELECT BANK1
MOVLW 0X00
;W REG=00
MOVWF TRISD
;SET RD AS OUTPUTS
BCF STATUS
,RP0; BANK 0
CLRF COUNT
; COUNT = 0 

MAIN MOVF COUNT
,W; GET COUNT
MOVWF PORTD
; OUTPUT W REG TO PORTD
CALL DELAY
CALL DELAY
INCF COUNT
; COUNT= COUNT+1
GOTO MAIN

 
; SUBRoUTINES
DELAY  
MOVLW 0X01
MOVWF DELAY_LO
MOVLW 0XA1
MOVWF DELAY_HI
MOVLW 0XFF
MOVWF DELAY_VHI

BIG
OUTER
INNER

INCFSZ DELAY_LO
,1
GOTO INNER
INCFSZ DELAY_HI
,1
GOTO OUTER
INCFSZ DELAY_VHI
GOTO INNER
RETURN
END




Post a reply
  Related Posts  to : Writing a Counter to any PORT
 C++ help with writing a program.     -  
 Reading and Writing To text file     -  
 Read XML file content using SAX and writing its as SQL     -  
 Writing a Windows Form Application For .NET Framework Using     -  
 jsp page counter     -  
 reset the list counter     -  
 File page counter in php     -  
 Use cookie to create page counter     -  
 Use cookie to create page counter     -  
 ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)     -