Advertisement
Guest User

Untitled

a guest
Sep 12th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Este es un comentario, esta es una plantilla
  2.     list p=18f4550          ;Modelo del microcontrolador
  3.     #include<p18f4550.inc>      ;Llamo a la librería de nombre de los regs
  4.    
  5.     ;Zona de los bits de configuración (falta)
  6.     CONFIG  FOSC = XT_XT      ; Oscillator Selection bits (XT oscillator (XT))
  7.     CONFIG  PWRT = ON             ; Power-up Timer Enable bit (PWRT enabled)
  8.     CONFIG  BOR = OFF             ; Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)
  9.     CONFIG  WDT = OFF             ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
  10.     CONFIG  PBADEN = OFF          ; PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
  11.     CONFIG  LVP = OFF             ; Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
  12.  
  13.     CONFIG  CCP2MX = ON           ; CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
  14.     CONFIG  MCLRE = ON            ; MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  15.    
  16. cuenta EQU 0x60; cuenta
  17.  
  18. ;   org 0x0100; tabla
  19. ;tablita db   0x00, 0xD8, 0x9C, 0x74, 0x01
  20. ;   org 0x0200; tabla2
  21. ;tablita2 db  0x00, 0x60, 0x9C, 0xC4, 0x01
  22.     ;0x3f, 0x06, 0x5b, 0x4f, 0x66
  23.     ;0,1,2,3,4
  24.  
  25.     org 0x0000; configuro
  26.     goto configuro
  27.    
  28.     org 0x0008;interrop
  29.     goto interroop
  30.    
  31.     org 0x0020;    
  32. configuro:
  33.     bcf TRISB, 4
  34.     clrf TRISD
  35.     clrf cuenta
  36.     ;movlw UPPER tablita
  37.     ;movwf TBLPTRU
  38.     ;movlw HIGH datos
  39.     ;movwf TBLPTRH
  40.     ;movlw LOW datos
  41.     ;movwf TBLPTRL  ;Punteando el TBLPTR
  42.     movlw 0xc8  ;b'11001000'
  43.     movwf T0CON
  44.     movlw 0xB0  ;b'11000000'
  45.     movwf INTCON    ;Interrupciones activas, INT0 habilitado
  46.     bcf INTCON2, INTEDG0    ;Detección en flanco negativo
  47.  
  48. inicio:
  49.     movlw .0
  50.     cpfseq cuenta
  51.     goto bla
  52.     goto cero   ;verdadero
  53.     movlw .4
  54.     cpfseq cuenta
  55.     goto nope
  56.     bsf LATB,4
  57.     goto otro
  58. tablasubida:
  59.     addwf PCL,f
  60.     dt 0xD8, 0x9C, 0x74
  61. tablabajada:
  62.     addwf PCL,f
  63.     dt 0x60, 0x9C, 0xC4
  64.    
  65. subida: movf cuenta, W
  66.     call tablasubida
  67.     movwf TMR0L
  68.     bcf INTCON,TMR0IF ;baja bandera
  69.    
  70. bajada: btfss INTCON,TMR0IF
  71.     goto bla2
  72.     movf cuenta, W
  73.     call tablabajada
  74.     movwf TMR0L
  75.     bcf INTCON, TMR0IF
  76.     goto inicio
  77.    
  78. nope:   nop
  79. interroop:  movlw .4
  80.         cpfseq cuenta
  81.         goto aunno
  82.         clrf cuenta
  83.         goto otro
  84. aunno:      incf cuenta, f
  85. otro:       bcf INTCON, INT0IF
  86.         retfie
  87. cero:       bcf LATB, 4
  88.         movlw 0x3f
  89.         movwf LATD
  90.         goto inicio
  91.    
  92.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement