Autor Tema: conteo para el 16f877 con LCD  (Leído 1852 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Guiden

  • PIC10
  • *
  • Mensajes: 1
conteo para el 16f877 con LCD
« en: 22 de Octubre de 2004, 15:40:00 »
 hola  :
    Espero me puedan ayudar para hacer una rutina de conteo con el pic 16f877 ya estoy utilizando un LCD y no se como hacer que me cambien los numeros del LCD, solo requiero contar hasta centenas osea por mucho 999 ya configure el timer1 como contador y ahora no se como desplegar los numeros correspondientes en el LCD ya que como sabemos este timer cuenta en binario y tiene TMRL y TMRH pero como hago para que lo que me vaya contando mi TMR1 lo vaya mostrando en el LCD.
          Si no me pudieras contestar esa pregunta y vistes este problemilla por la red porfa mandame la pag de donde lo viste.

         NOTAS : El LCD es de 2*16 y solo estoy ocupando las  ultimas 3 direcciones de la ddram porque en lo dems estoy desplegando un mensaje


                                                                        GRACIAS

Desconectado Golden_Eagle

  • PIC16
  • ***
  • Mensajes: 135
RE: conteo para el 16f877 con LCD
« Respuesta #1 en: 22 de Octubre de 2004, 21:10:00 »
creo q esto deveria ayudarte con tu problema..
Codigo:

;****************************************************************
; Signed 16-bit to ASCII converter. Enter with number in hi/lo.
; returns with ASCII equivelent at . The first char will
; be sign: "-" or " ". The latter is easily changed to "+".
; Leading spaces are not supressed.  Uses program 65 words.

toascii   movlw   ascii      ; setup a pointer
   movwf   fsr
   btfss   hi,7      ; negative number?
   goto   skpneg      ; no

   comf   hi      ; negate the number
   comf   lo
   incf   lo
   btfsc   status,z
   incf   hi
   movlw   "-"      ; provide a negative sign
   goto   minus

skpneg   movlw   " "      ; blank "sign" for positive
minus   movwf   indf      ; store sign
   incf   fsr      ; fill ascii buffer with ("0"-1)
   movlw   "0"-1
   movwf   indf
   incf   fsr
   movwf   indf
   incf   fsr
   movwf   indf
   incf   fsr
   movwf   indf

   movlw   ascii+1      ; do the subtractions
   movwf   fsr
   dodigit   10000
   dodigit   1000
   dodigit   100
   dodigit   10
   movf   lo,w      ; ls byte is already correct
   addlw   "0"      ; convert to ascii
   movwf   indf
   return         ; done

; Subtract the number in shi/slo from hi/lo until the result
; is negative, incrementing the ascii equivelent each time.

dosub   incf   indf      ; increment ASCII character
   movf   slo,w      ; subtract current power of 10
   subwf   lo,f
   movf   shi,w
   btfss   STATUS,C
   addlw   1
   subwf   hi,f
   btfsc   STATUS,C   ; any carry?
   goto   dosub      ; no, keep subtracting

   movf   slo,w      ; reverse the last subtraction
   addwf   lo,f
   movf   shi,w
   btfsc   STATUS,C
   addlw   1
   addwf   hi,f
   incf   fsr      ; step to next ASCII position
   return




Saludos!


 

anything