• Domingo 29 de Septiembre de 2024, 01:18

Autor Tema:  Pic16f88  (Leído 2205 veces)

thevy

  • Nuevo Miembro
  • *
  • Mensajes: 7
    • Ver Perfil
Pic16f88
« en: Martes 29 de Enero de 2008, 22:48 »
0
hola quisiera me pudieran ayudar, con algo: quiero grabar un programa en el pic16f88, quiero recibir un valor de un voltimetro luego convertirlo a señal digital para luego enviarlo por medio del puerto serie..... se puede? dejo mi correo por cualquier cosa,,, please help me,,,,, sandrathevy@hotmail.com

thevy

  • Nuevo Miembro
  • *
  • Mensajes: 7
    • Ver Perfil
Re: Pic16f88
« Respuesta #1 en: Jueves 7 de Febrero de 2008, 23:55 »
0
HOLA TENGO ESTE COD PERO ME DA UN ERROR EN EL CONFIG.. ALGUIEN ME AYUDA?
Código: Text
  1.  
  2. ;------------------------------------------------------------
  3. ; Código assembler generado por Niple V5.2.1
  4. ; Proyecto: Voltimetro Digital
  5. ; Autor: ---
  6. ; Fecha: 07/02/2008
  7. ; PIC: 16F88
  8. ; Velocidad de reloj: 4 Mhz
  9. ; Descripcion: Medir un voltaje cada segundo y mostrar el resultado. enviarlo por el puerto serial
  10. ;------------------------------------------------------------
  11.  
  12.  
  13.  LIST    P=PIC16F88
  14.  
  15.  
  16. _XT_OSC             equ  0x3FFD
  17. _DEBUG_OFF          equ  0x3FFF
  18. _WDT_OFF            equ  0x3FFB
  19. _PWRTE_ON           equ  0x3FF7
  20. _BODEN_OFF          equ  0x3FBF
  21. _LVP_OFF            equ  0x3F7F
  22. _CPD_OFF            equ  0x3FFF
  23. _CP_OFF             equ  0x3FFF
  24. ;_WRT_ENABLE_OFF     equ  0x3DFF
  25.  
  26.  __config _XT_OSC & _DEBUG_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
  27.  
  28.  
  29. ;------------------------------------------------------------
  30. ;                  Declaración de Registros
  31. ;------------------------------------------------------------
  32. w                     equ  0x0000
  33. status                equ  0x0003
  34. portb                 equ  0x0006
  35. pclath                equ  0x000a
  36. adresh                equ  0x001e
  37. adcon0                equ  0x001f
  38. voltaje_1             equ  0x0021
  39. voltaje_2             equ  0x0022
  40. _np_temp1             equ  0x0023
  41. _np_temp2             equ  0x0024
  42. _np_temp3             equ  0x0025
  43. _np_temp4             equ  0x0026
  44. _np_temp5             equ  0x0027
  45. _np_rs232_t           equ  0x0028
  46. _np_rs232_t1          equ  0x0029
  47. _np_config_interrup   equ  0x002a
  48. _np_tiempo            equ  0x002c
  49. _np_tiempo1           equ  0x002e
  50. _np_tiempo2           equ  0x002f
  51. _np_tiempo3           equ  0x0030
  52. trisa                 equ  0x0085
  53. trisb                 equ  0x0086
  54. adresl                equ  0x009e
  55. adcon1                equ  0x009f
  56.  
  57.  
  58. ;------------------------------------------------------------
  59. ;                  Declaración de Bits
  60. ;------------------------------------------------------------
  61. adfm                  equ  7  &#59;
  62. adon                  equ  0  &#59;
  63. c                     equ  0  &#59;carry / borrow bit
  64. go_done               equ  2  &#59;
  65. rp0                   equ  5  &#59;registrer bank select bit
  66. rp1                   equ  6  &#59;registrer bank select bit
  67. z                     equ  2  &#59;bit cero
  68.  
  69.  
  70. ;------------------------------------------------------------
  71. ;                        Inicio
  72. ;------------------------------------------------------------
  73.  
  74. reset   org 0
  75.    goto paso2
  76.    org 4
  77.    retfie
  78.  
  79.  
  80. ;------------------------------------------------------------
  81. ;                      programa principal
  82. ;------------------------------------------------------------
  83. paso2
  84.    movlw b'00000001'               &#59;configurar el puerto a como xxsssssa
  85.    bsf status,rp0                  &#59;cambiar a banco 1
  86.    bcf status,rp1
  87.    movwf trisa
  88.    movlw b'10001110'               &#59;configuracion a/d = dddda
  89.    movwf adcon1
  90.    bcf status,rp0                  &#59;cambiar a banco 0
  91.    bsf adcon0,adon                 &#59;activar activar el conversor a/d.
  92.    movlw b'00000000'               &#59;configurar el puerto b como ssssssss
  93.    bsf status,rp0                  &#59;cambiar a banco 1
  94.    movwf trisb
  95. paso5
  96.    movlw b'10000001'               &#59;conversión
  97.    bcf status,rp0                  &#59;cambiar a banco 0
  98.    bcf status,rp1
  99.    movwf adcon0
  100.    bsf status,rp0                  &#59;cambiar a banco 1
  101.    bsf adcon1,adfm                 &#59;alinear el resultado a la derecha
  102.    bcf status,rp0                  &#59;cambiar a banco 0
  103.    clrf _np_temp3
  104.    clrf _np_temp4
  105.    movlw .16
  106.    movwf _np_temp5
  107. paso5_ciclos
  108.    call leer_ad
  109.    bsf status,rp0                  &#59;cambiar a banco 1
  110.    movf adresl,w                   &#59;recuperar el registro bajo de la conversion a/d
  111.    bcf status,rp0                  &#59;cambiar a banco 0
  112.    movwf voltaje_2
  113.    movf adresh,w                   &#59;recuperar el registro alto de la conversion a/d
  114.    movwf voltaje_1
  115.    movf voltaje_2,w
  116.    addwf _np_temp4,1
  117.    btfsc status,c
  118.    incf _np_temp3,1
  119.    movf voltaje_1,w
  120.    addwf _np_temp3,1
  121.    decfsz _np_temp5,1
  122.    goto paso5_ciclos
  123.    bcf status,c
  124.    rrf _np_temp3,1
  125.    rrf _np_temp4,1
  126.    bcf status,c
  127.    rrf _np_temp3,1
  128.    rrf _np_temp4,1
  129.    bcf status,c
  130.    rrf _np_temp3,1
  131.    rrf _np_temp4,1
  132.    bcf status,c
  133.    rrf _np_temp3,1
  134.    rrf _np_temp4,1
  135.    movf _np_temp3,w
  136.    movwf voltaje_1
  137.    movf _np_temp4,w
  138.    movwf voltaje_2
  139.    movf voltaje_1,w                &#59;enviar el dato voltaje_1
  140.    movwf _np_temp1
  141.    call rs232_tb1_9600
  142.    movlw .1                        &#59;temporizador 1 seg
  143.    call tiempo_1_255_mega_c
  144.    goto paso5                      &#59;cierra el ciclo
  145.  
  146.  
  147. ;------------------------------------------------------------
  148. ;                  Declaración de Subrutinas
  149. ;------------------------------------------------------------
  150.  
  151. tiempo_1_255_mega_c
  152.    movwf _np_tiempo
  153.    goto tiempo_1_255_mega_c_1
  154. tiempo_1_255_mega_c_bucle2
  155.    nop
  156.    nop
  157.    nop
  158.    nop
  159.    nop
  160.    nop
  161.    nop
  162. tiempo_1_255_mega_c_1
  163.    movlw .10
  164.    movwf _np_tiempo1
  165. tiempo_1_255_mega_c_bucle1
  166.    nop
  167.    nop
  168.    movlw .99
  169.    movwf _np_tiempo2
  170. tiempo_1_255_mega_c_bucle0
  171.    nop
  172.    nop
  173.    nop
  174.    movlw .200
  175.    movwf _np_tiempo3
  176. tiempo_1_255_mega_c_bucle
  177.    nop
  178.    nop
  179.    decfsz _np_tiempo3,1
  180.    goto tiempo_1_255_mega_c_bucle
  181.    nop
  182.    nop
  183.    nop
  184.    decfsz _np_tiempo2,1
  185.    goto tiempo_1_255_mega_c_bucle0
  186.    nop
  187.    nop
  188.    nop
  189.    decfsz _np_tiempo1,1
  190.    goto tiempo_1_255_mega_c_bucle1
  191.    decfsz _np_tiempo,1
  192.    goto tiempo_1_255_mega_c_bucle2
  193.    return
  194.  
  195.  
  196. leer_ad
  197.   &#59;realizar conversion a/d
  198.    movlw .200
  199.    movwf _np_temp1
  200.    bsf adcon0,go_done
  201. leer_ad_esperar
  202.    decfsz _np_temp1,1
  203.    goto leer_ad_esperar
  204.    nop
  205.    nop
  206. leer_ad_esperar_fin
  207.    btfsc adcon0,go_done
  208.    goto leer_ad_esperar_fin
  209.    return
  210.  
  211. rs232_tb1_9600
  212.   &#59;enviar un dato rs232 por portb,1 (por codigo)
  213.   &#59;_np_temp1 = dato a enviar
  214.   &#59;_np_temp2 = contador de bits
  215.    movlw .8
  216.    bcf status,rp0                  &#59;cambiar a banco 0
  217.    bcf status,rp1
  218.    movwf _np_temp2
  219.    bcf portb,1
  220.    call rs232_9600_bit
  221. rs232_tb1_9600_tx_otro
  222.    bcf portb,1
  223.    bcf status,c
  224.    rrf _np_temp1,1
  225.    btfsc status,c
  226.    bsf portb,1
  227.    call rs232_9600_bit
  228.    decfsz _np_temp2,1
  229.    goto rs232_tb1_9600_tx_otro
  230.    bsf portb,1
  231.    call rs232_9600_bit
  232.    return
  233.  
  234.  
  235. rs232_9600_bit
  236.    movlw .9
  237.    movwf _np_rs232_t
  238.    goto rs232_9600_bit_2
  239. rs232_9600_bit_bucle
  240.    nop
  241.    nop
  242.    nop
  243.    nop
  244.    nop
  245.    nop
  246.    nop
  247. rs232_9600_bit_2
  248.    decfsz _np_rs232_t,1
  249.    goto rs232_9600_bit_bucle
  250.    nop
  251.    nop
  252.    nop
  253.    nop
  254.    nop
  255.    nop
  256.    nop
  257.    nop
  258.    nop
  259.    return
  260. rs232_9600_mbit
  261.    movlw .4
  262.    movwf _np_rs232_t
  263.    goto rs232_9600_mbit_2
  264. rs232_9600_mbit_bucle
  265.    nop
  266.    nop
  267.    nop
  268.    nop
  269.    nop
  270.    nop
  271.    nop
  272. rs232_9600_mbit_2
  273.    decfsz _np_rs232_t,1
  274.    goto rs232_9600_mbit_bucle
  275.    nop
  276.    nop
  277.    nop
  278.    nop
  279.    nop
  280.    nop
  281.    nop
  282.    nop
  283.    nop
  284.    return
  285.  
  286.  End
  287.  
  288.