Edit: den använder väll MCLR?
Kod: Markera allt
;****************************************************************
;* Name of Project: Experiment 1 *
;* Push red button RB0 to turn on red LED RB4 *
;****************************************************************
list P = 16F628 ;microcontroller identity
; e.g: 0x033 = hex value
__Config 3F18h
;****************************************************************
;Equates
;****************************************************************
status equ 0x03
cmcon equ 0x1F
rp1 equ 0x06 ;this is bit 6 in file 03
rp0 equ 0x05 ;this is bit 5 in file 03
;****************************************************************
;Beginning of program
;****************************************************************
reset: org 0x00 ;reset vector address
goto SetUp ;goto set-up
nop
nop
nop
org 4 ;interrupts go to this location
goto isr1 ;goto to Interrupt Routine - not used
; in these experiments.
;isr1 must be written at address 004
; otherwise bcf status,rp1 will be
; placed at address 01 by assembler!
;****************************************************************
;* Port A and B initialisation *
;****************************************************************
SetUp bcf status,rp1 ;select bank 1
bsf status,rp0
movlw 0xFF ;make all Port A inputs
movwf 0x05
movlw 0x0F ; out out out out in in in in
movwf 0x06 ;
bcf status,rp0 ;select programming area - bank0
movlw 0x07 ;turn comparators off and enable
movwf cmcon ; pins for I/O functions
goto Main
;****************************************************************
;* Interrupt Service Routine will go here (not used) *
;****************************************************************
isr1
;****************************************************************
;* Main *
;****************************************************************
Main btfss 0x06,0 ;Port B, input bit 0 = red button pushed?
goto Main1
bsf 0x06,4 ;Port B, output bit 4 = turn on red LED
goto Main
Main1 bcf 0x06,4 ;Port B, output bit 4 = turn off red LED
goto Main
END