Autor Tema: Problema haciendo un reloj digital con Pic Basic Pro  (Leído 3230 veces)

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

Desconectado escarrillense

  • PIC10
  • *
  • Mensajes: 41
Problema haciendo un reloj digital con Pic Basic Pro
« en: 24 de Noviembre de 2011, 13:18:31 »
Hola! Soy nuevo en este foro. Necesito ayuda para hacer un reloj digital con Pic Basic Pro. Estoy programando en MikroBasic Pro 5.01 y al compilar no me salen errores, pero a la hora de probarlo en Proteus no me funciona y no se donde esta el error. Agradezco vuestra atencion. El programa es el siguiente:

symbol boton_horas = portb.0
symbol boton_minutos = portb.1

dim LCD_RS as sbit  at RB3_bit
    LCD_EN as sbit  at RA4_bit
    LCD_D4 as sbit  at RA0_bit
    LCD_D5 as sbit  at RA1_bit
    LCD_D6 as sbit  at RA2_bit
    LCD_D7 as sbit  at RA3_bit

    LCD_RS_Direction as sbit at TRISB3_bit
    LCD_EN_Direction as sbit at TRISA4_bit
    LCD_D4_Direction as sbit at TRISA0_bit
    LCD_D5_Direction as sbit at TRISA1_bit
    LCD_D6_Direction as sbit at TRISA2_bit
    LCD_D7_Direction as sbit at TRISA3_bit

' End Lcd module connections

      dim ticks as byte
      dim horas as byte
      dim minutos as byte
      dim segundos as byte
      dim disp as byte
      dim Delay as byte


'Rutina de atencion a la interrupcion (RAI)
sub procedure RAI
        ticks = ticks + 1
        if ticks <61 then intcon.2 = 0
        Ticks = 0
        segundos = segundos +1            'Actualizar segundos
        if segundos = 60 then
           segundos = 0
           minutos = minutos +1         'Actualizar minutos
           else
           if minutos = 60 then
              minutos = 0
              horas = horas + 1         'Actualizar horas
              else
              if horas = 24 then
                 horas = 0
              end if
           end if
        end if
        end if

        disp = 1
end sub

'Rutina para eliminar los rebotes de los pulsadores
sub procedure Rebote
         for Delay = 1 to 200
             Delay_ms (1)
         next Delay
         disp = 1
end sub

main:
     
       trisa = 0            'Puerto A es salida
       trisb = 3            'RB0, RB1 entradas
       cmcon = 7            'Puerto A, E/S digital

'Inicializar la interrupcion del temporizador
        option_reg = $05          'Prescalador = 64
        RAI                       'Rutina RAI
        intcon = $A0              'Habilitar las interrupciones TMR0 y Global

   horas = 0
        minutos = 0
        segundos = 0
        ticks = 0

        Delay_ms (500)       'Esperar 0.5 seg para iniciar el LCD

         Lcd_Init()                     ' Initialize Lcd
         Lcd_Cmd(_LCD_CLEAR)            ' Clear display
         Lcd_Cmd(_LCD_CURSOR_OFF)       ' Cursor off
         Lcd_Out(1,3,"dec (horas) : dec(minutos) : dec(segundos)")

'Chequeo pulsador de horas y si esta pulsado, incrementar variable hour
         if boton_horas = 0 then
            horas = horas + 1
            if horas = 24 then horas = 0
            Rebote
            end if
         end if

'Chequeo pulsador de minutos y si esta pulsado, incrementar variable minute
         if boton_minutos = 0 then
            minutos = minutos + 1
            if minutos = 60 then minutos = 0
            Rebote
            end if
         end if

'Segmento para actualizar el LCD
          if disp = 1 then
             Lcd_Out(1,3,"dec (horas) : dec(minutos) : dec(segundos)")
             disp = 0
          end if
          goto main

end.