Making timer using DT_INT, problem with LCD (Using it first time)


Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default Making timer using DT_INT, problem with LCD (Using it first time)

    Hi, I am using a LCD for the first time so please forgive me for any mistakes and I have searched few threads and picked up few pieces to put together.
    This is my code:
    Code:
    INCLUDE "modedefs.bas"
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    DEFINE OSC 4
    
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 1500
    DEFINE LCD_DATAUS 44
    
    sec var byte
    minu var byte
    hrs var byte
    days var word
    
    ADCON1=7
    CMCON=7
    OPTION_REG=128
    TRISA=0 : PORTA=0
    TRISB=0 : PORTB=0
    TRISC=0 : PORTC=0
    TRISD=0 : PORTD=0
    TRISE=0 : PORTE=0
    CCP1CON=0
    
    @ ERRORLEVEL -306
    
    wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
    
    gosub reset
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
           INT_Handler    TMR1_INT,  _counting,   PBP,  yes
       endm
      INT_CREATE               ; Creates the interrupt processor
    ENDASM
    T1CON=%00110000
    TMR1L=%11011100
    TMR1H=%00001011
    
    @   INT_ENABLE   TMR1_INT     ; enable external (INT) interrupts
    PAUSE 1000
    Main3:
    LCDOUT "HELLO" ;$FE,1,2, DEC days,"d-",DEC2 hrs,":",DEC2 Minu,":",DEC2 Sec
    GOTO Main3
    
    RESET:
    sec=0 : minu=0 : hrs=0 : days=0
    return
    
    '---[INT - interrupt handler]---------------------------------------------------
    counting:
         sec=sec+1
    	if sec =120 then
    		sec=0
    		minu=minu+1
    		if minu=120 then
    			minu=0
    			hrs=hrs+1
    			if hrs=48 then
    				hrs=0
    				days=days+1
    			endif
    		endif
    	endif
    	TMR1L=%11011100
    	TMR1H=%00001011
    @ INT_RETURN
    I am aware there is an elapsed timer file which can do this, but I am in a spirit of doing something myself. Once I am able to control the LCD properly, I will be trying to modify the main code to make my own 7 days timer.
    I am using 16F877A and the connections page snapshot of the LCD is attached. I am using Matrix Multimedia's development board.
    Thanks in advance.
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You may just need to increse the delay times.

    Code:
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    DT

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts