Blogia
microcontroladores1

Programa de 20% Lab. de Mc

 list p = 16f84
 radix hex
estado equ 03
portA equ 05
portB equ 06
tmr0_op equ 01
reg1 equ 0c
reg2 equ 0d
reg3 equ 0e
reg4 equ 0f
reg5 equ 10
reg6 equ 11
reg7 equ 12
reg8 equ 13
delay1 equ 14
delay2 equ 15

  org 00
  bsf estado,5
  movlw 0ff
  movwf portA
  clrf portB
  movlw 07
  movwf tmr0_op
  bcf estado,5
inicio: movlw 00
  movwf reg1
  movlw 01
  movwf reg2
  movlw 02
  movwf reg3
  movlw 03
  movwf reg4
  movlw 04
  movwf reg5
  movlw 05
  movwf reg6
  movlw 06
  movwf reg7
  movlw 07
  movwf reg8
ave: movf portA,0
  andlw 07
  subwf reg1,0
  btfsc estado,2
  goto jon1
  movf portA,0
  andlw 07
  subwf reg2,0
  btfsc estado,2
  goto jon2
  movf portA,0
  andlw 07
  subwf reg3,0
  btfsc estado,2
  goto jon3
  movf portA,0
  andlw 07
  subwf reg4,0
  btfsc estado,2
  goto jon4
  movf portA,0
  andlw 07
  subwf reg5,0
  btfsc estado,2
  goto jon5
  movf portA,0
  andlw 07
  subwf reg6,0
  btfsc estado,2
  goto jon6
  movf portA,0
  andlw 07
  subwf reg7,0
  btfsc estado,2
  goto jon7
  movf portA,0
  andlw 07
  subwf reg8,0
  btfsc estado,2
  goto jon8
jon1: bsf portB,0
  call retar1
  bcf portB,0
  call retar1
  btfsc portA,3
  goto ave
  goto jon1
jon2: bsf portB,0
  call retar2
  bcf portB,0
  call retar2
  btfsc portA,3
  goto ave
  goto jon2
jon3: bsf portB,0
  call retar3
  bcf portB,0
  call retar3
  btfsc portA,3
  goto ave
  goto jon3
jon4: bsf portB,0
  call retar4
  bcf portB,0
  call retar4
     btfsc portA,3
  goto ave
  goto jon4
jon5: bsf portB,0
  call retar5
  bcf portB,0
  call retar5
  btfsc portA,3
  goto ave
  goto jon5
jon6: bsf portB,0
  call retar6
  bcf portB,0
  call retar6
  btfsc portA,3
  goto ave
  goto jon6
jon7: bsf portB,0
  call retar7
  bcf portB,0
  call retar7
  btfsc portA,3
  goto ave
  goto jon7
jon8: bsf portB,0
  call retar8
  bcf portB,0
  call retar8
  btfsc portA,3
  goto ave
  goto jon8
retar1: movlw d'16'
  movwf delay1
ken1: btfss 0b,2
  goto  ken1
  bcf 0b,2
  decfsz delay1,1
  goto ken1
  return
retar2: movlw d'8'
  movwf delay1
ken2: btfss 0b,2
  goto ken2
  bcf 0b,2
  decfsz delay1,1
  goto ken2
  return
retar3:   movlw d'60'
  movwf tmr0_op
ken3: btfss 0b,2
  goto ken3
  bcf 0b,2
  return
retar4: movlw d'223'
  movwf tmr0_op
ken4: btfss 0b,2
  goto ken4
  bcf 0b,2
  return
retar5: movlw d'251'
  movwf tmr0_op
ken5: btfss 0b,2
  goto ken5
  bcf 0b,2
  return  
retar6: movlw d'253'
  movwf tmr0_op
ken6: btfss 0b,2
  goto ken6
  bcf 0b,2
  return 
retar7: movlw d'16'
  movwf delay2
ken7: decfsz delay2,1
  goto ken7
  return
retar8: nop
  return
  end

0 comentarios