Hallo,
Morgen moet ik alle poorten in een pic16F887 programmeren op school in assembly...
Nu heb eigenlijk totaal Geen ervaring maar heb toch al enkele poortjes kunnen programmeren...
Nu mijn vraag was of er een site is waar dat al gedaan (dan kan ik gewoon copie pasten) of is of er iemand mij kan helpen om aan de rest van die poortjes te graken?
NEN Poort
list p=16f887 ; list directive to define processor
#include <p16f887.inc> ; processor specific variable definitions
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
;***** VARIABLE DEFINITIONS
INT_VAR UDATA_SHR
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
pclath_temp RES 1 ; variable used for context saving
;**********************************************************************
ORG 0x000 ; processor reset vector
goto START ; go to beginning of program
START
BANKSEL ANSEL
CLRF ANSEL
BANKSEL ANSELH
CLRF ANSELH
BANKSEL TRISA
CLRF TRISA
banksel TRISB
clrf TRISB
movlw b'00000011'
BANKSEL PORTA
movwf PORTA
banksel PORTB
clrf PORTB
movlw b'00000000'
BTFSS PORTA,0
goto Opdracht1
btfsc PORTA,0
goto Opdracht2
Opdracht1
Movlw b'00000001'
goto einde
Opdracht2
BTFSS PORTA,1
MOVLW b'00000001'
goto einde
einde
movwf PORTB
goto START
END
NOF-poort
list p=16f887 ; list directive to define processor
#include <p16f887.inc> ; processor specific variable definitions
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
;***** VARIABLE DEFINITIONS
INT_VAR UDATA_SHR
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
pclath_temp RES 1 ; variable used for context saving
;**********************************************************************
ORG 0x000 ; processor reset vector
goto START ; go to beginning of program
Poort1nul
btfss PORTA,1 ;Kijkt of de tweede bit 0 is => zet 1 in het werkregister
movlw b'00000001'
return
START
banksel ANSEL ;Initialiseren waarden
clrf ANSEL
banksel ANSELH
clrf ANSELH
banksel TRISA
clrf TRISA
banksel TRISB
clrf TRISB
movlw b'00000000' ;Waarden aan de ingang van de NOF-poort
banksel PORTA
movwf PORTA
banksel PORTB
clrf PORTB
movlw b'00000000'
main ;Start main
btfss PORTA,0 ;Kijkt of de eerste bit 0 is => roept het poort1nul subroutine aan
call Poort1nul
movwf PORTB ;Zet het werkregister in poort B
goto main
end
OR poort
ist p=16f887 ; list directive to define processor
#include <p16f887.inc> ; processor specific variable definitions
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
;***** VARIABLE DEFINITIONS
INT_VAR UDATA_SHR
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
pclath_temp RES 1 ; variable used for context saving
;**********************************************************************
ORG 0x000 ; processor reset vector
goto START ; go to beginning of program
instructie1
btfsc PORTB,0 ;portb bit0=0 ga dan 1 instructie verder
Movlw b'00000001' ;w krijgt de waarde van 00000001
btfss PORTB,0 ;portb bit 0=1 ga dan 1 instreuctie verder
Movlw b'00000000' ;WREG krijgt de waarde van 00000000
call EINDE ;ga naar EINDE
RETURN
EINDE
movwf PORTB ; PORTB krijgt de waarde van WREG
call START ; ga naar START
retlw 0x00
START
BANKSEL ANSEL ; bankselectie ANSEL
CLRF ANSEL ; digitale I/O
BANKSEL ANSELH; bankselectie ANSELH
CLRF ANSELH ; digitale I/O
BANKSEL TRISA ; bankselectie TRISA
CLRF TRISA ; digitale I/O
banksel TRISB ; bankselectie TRISA
clrf TRISB ; digitale I/O
movlw b'00000001' ; WREG krijgt de waarde van 00000011
BANKSEL PORTA ; bankselectie PORTA
movwf PORTA ; PORTA krijgt de waarde van WREG
banksel PORTB ; bankselectie PORTB
clrf PORTB ; digitale I/O
movlw b'00000000' ; w krijgt de waarde van 00000001
movwf PORTB
main
instructie2
BTFSS PORTA,0 ; PORTA bit0=1, ja,dan spring 1 instructie
call instructie1 ; ga naar label Opdracht1
btfsc PORTA,0 ;PORTA bit0=0 ja, dan spring 1 instructie
movwf PORTB;zet WREG in portb
goto instructie2
END
Nu moet ik alleen
NOT, AND, EXOF, EXNOF zien te kunnen programmeren
Alvast bedankt
nonkel_dw
nonkel dw
Hmm... Wat is hier het nut van?
;bv voor een and:
main:
btfss schakelaar1
goto main
btfss schakelaar2
goto main
bsf uitgang
de rest is toch niet zo moeilijk meer...
klein is fijn
Moderator
Misschien handig om even de datasheet van het ding in te duiken? AND, OR, XOR, increment en dergelijke functies zitten standaard in de instructieset. Gooi wat je inleest van de pinnen in de lsb van 2 bytes, leef je uit en schrijf het lsb terug naar een uitgang.