Tagli said:TRIS instruction is used in old PIC models...
;**********************************************************************
; This file is a basic code template for object module code *
; generation on the PIC16F876. *
; This code cycles a bit parttern through the LEDs on PORTB. *
; *
; THE PROGRAM DISPLAYS LEDs ON PORTB IN SEQUENCE *
;**********************************************************************
; *
; Filename: COUNTER.asm *
; Date: *
; File Version: *
; *
; Author: CHARLES NENGUKE *
;**********************************************************************
; *
; Files required: P16F876.INC *
;**********************************************************************
list p=16f876 ; list directive to define processor
#include <p16f876.inc> ; processor specific variable definitions
radix hex
__CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF
STATUS EQU 0x03
PORTB EQU 0x06
SHIFT EQU 0x0C
NCOUNT EQU 0x0D
MCOUNT EQU 0x0E
C EQU 0
;=======================================================================
org 0x0000
;
start movlw 0x00 ; load W with 0x00
banksel TRISB ; make PORTB pins outputs
movwf PORTB ; make PORTB lines low
bcf STATUS,C ; clear the carry flag
clrf PORTB ; PORTB lines low
movlw b'01001001' ; initialize counter
movwf SHIFT ; store the value b'01001001' in SHIFT register
GET_BIT movf SHIFT,W ; move from register SHIFT to W
movwf PORTB ; display output at port b
call PAUSE ; delay via subroutine PAUSE
RLF SHIFT,f ; rotate the bits in register SHIFT and store the
; result in SHIFT
goto GET_BIT ; start all over again
PAUSE movlw 0xFF ; M
movwf MCOUNT ; move contents of W to MCOUNT
LOADN movlw 0x0F ; N
movwf NCOUNT ; move contents of W to register NCOUNT
DECN decfsz MCOUNT,f ; decrement M
goto LOADN ; repaet operation
return ; done
;
end
bsf STATUS,RP0
bcf STATUS,RP1
;**********************************************************************
; This file is a basic code template for object module code *
; generation on the PIC16F876. *
; This code cycles a bit parttern through the LEDs on PORTB. *
; *
; THE PROGRAM DISPLAYS LEDs ON PORTB IN SEQUENCE *
;**********************************************************************
; *
; Filename: COUNTER.asm *
; Date: *
; File Version: *
; *
; Author: CHARLES NENGUKE *
;**********************************************************************
; *
; Files required: P16F876.INC *
;**********************************************************************
list p=16f876 ; list directive to define processor
#include <p16f876.inc> ; processor specific variable definitions
radix hex
__CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF
STATUS EQU 0x03
PORTB EQU 0x06
SHIFT EQU 0x0C
NCOUNT EQU 0x0D
MCOUNT EQU 0x0E
C EQU 0
;=======================================================================
org 0x0000
;
start bsf STATUS,RP0
bcf STATUS,RP1
movlw 0x00 ; load W with 0x00
banksel 86h ; make PORTB pins outputs
movwf 86h ; make PORTB lines low
bcf STATUS,C ; clear the carry flag
clrf PORTB ; PORTB lines low
movlw b'01001001' ; initialize counter
movwf SHIFT ; store the value b'01001001' in SHIFT register
GET_BIT movf SHIFT,W ; move from register SHIFT to W
movwf PORTB ; display output at port b
call PAUSE ; delay via subroutine PAUSE
RLF SHIFT,f ; rotate the bits in register SHIFT and store the
; result in SHIFT
goto GET_BIT ; start all over again
PAUSE movlw 0xFF ; M
movwf MCOUNT ; move contents of W to MCOUNT
LOADN movlw 0xFF ; N
movwf NCOUNT ; move contents of W to register NCOUNT
DECN decfsz MCOUNT,f ; decrement M
goto LOADN ; repaet operation
return ; done
;
end
banksel TRISB ;switches to Bank 1
clrf TRISB ;clears TRISB, thus making them outputs
banksel PORTB ;switches to Bank 0
bsf STATUS,RP0 ;switches to Bank 1
clrf TRISB ;clears TRISB, thus making them outputs
bcf STATUS,RP0 ;switches to Bank 0
__CONFIG _LVP_OFF
errorlevel -302
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?