MikroElektronika PIC Microcontrollers PIC16 Especificaciones Pagina 236

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 266
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 235
mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix B: Examples
HIcnt
LOcnt
LOOPcnt
cnt
endc ; End of block of variables
;**********************************************************************
ORG 0x000 ; Reset vector
nop
goto main ; Go to program start (label "main")
;**********************************************************************
include "pause.inc"
include "button.inc"
;**********************************************************************
main
banksel ANSEL ; Selects bank containing ANSEL
clrf ANSEL ; All pins are digital
clrf ANSELH
banksel TRISB
bsf TRISA, 0
bsf TRISA, 1
clrf TRISB
banksel PORTB
clrf cnt
Loop
button PORT,0,0,Increment
button PORT,1,0,Decrement
goto Loop
Increment
incf cnt, f
movf cnt, w
movwf PORTB
goto Loop
Decrement
decf cnt, f
movf cnt, w
movwf PORTB
goto Loop
end ; End of program
Macro "pausems"
;**********************************************************************
pausems MACRO arg1
local Loop1
local dechi
local Delay1ms
local Loop2
local End
movlw High(arg1) ; Higher byte of argument is moved
; to HIcnt
movwf HIcnt
movlw Low(arg1) ; Lower byte of argument is moved
; to LOcnt
movwf LOcnt
Loop1
movf LOcnt, f ; Decrements HIcnt and LOcnt while
btfsc STATUS, Z ; needed and calls subroutine Delay1ms
goto dechi
call Delay1ms
decf LOcnt, f
goto Loop1
dechi
movf HIcnt, f
http://www.mikroe.com/en/books/picmcubook/appb/ (31 of 54)5/3/2009 11:36:02 AM
Vista de pagina 235
1 2 ... 231 232 233 234 235 236 237 238 239 240 241 ... 265 266

Comentarios a estos manuales

Sin comentarios