Clock and Dual Termometer


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thanks for support ! I changed the name, but...
    Attached Images Attached Images  

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi,
    It compiles here. I renamed the interrupt handler to ISR (changed the label) and adjusted the DT-Ints declaration accordingly:
    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR0_INT,   ISR,   ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
        INT_ENABLE  TMR0_INT     ; Enable Timer 0 Interrupts  
    ENDASM
    And
    Code:
    ASM
    ;******************************************************************************
    ;  INTERRUPT HANDLER     (runs this code each timer0 interrupt)
    ;******************************************************************************
    ;------------------
    ISR 
    ;------------------
    I compiled it for a 16F628A for which I had to add
    Code:
    INCLUDE DT_Ints-14.bas
    wsave VAR BYTE $70 SYSTEM
    wsave1 VAR BYTE $A0 SYSTEM
    wsave2 var BYTE $120 SYSTEM
    Make sure your compiling "from" the main source file and not from within the timp.pbp.txt file.

    /Henrik.

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thanks for support ! Yes, in this way I compiled the code. Unfortunately the result are so strange ...the display show random numbers - quickly changed, the errors messages are without end
    Attached Images Attached Images  
    Last edited by fratello; - 26th January 2011 at 12:46.

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    OK, now the code for clock works fine now.
    Let's return to my sheeps ...How can I put in "timp.pbp.txt" the code for reading the two DS18B20 ? The author say : "Add your own code here for your one second event". How can I make this ? I don't have a clue...
    Code:
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    
    ASM
    
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_HANDLER  TMR0_INT,  PISR,   ASM,  yes
        endm
        INT_CREATE               	; Creates the interrupt processor
    
        INT_ENABLE  TMR0_INT     	; Enable Timer 1 Interrupts  
    
    ENDASM
    
    
           OPTION_REG = %00001000	' Set TMR0 configuration
           INTCON = %10100000	' Enable TMR0 interrupts
    
    
    		bres_hi	VAR	BYTE bank0 system		' hi byte of our 24bit variable
    		bres_mid	VAR	BYTE bank0 system		; mid byte
    		bres_lo	VAR	BYTE bank0 system		; lo byte
    						
    bres_hi = $0F
    bres_mid= $42
    bres_lo= $40
    
    		tick	VAR	BYTE bank0 system
    
    ASM
    ;******************************************************************************
    ;  INTERRUPT HANDLER     (runs this code each timer0 interrupt)
    ;******************************************************************************
    ;
    ;------------------
    PISR			;
    ;------------------
    
    	tstf bres_mid			  ; first test for mid==0
    	skpnz				        ; nz = no underflow needed
    	decf bres_hi,f			  ; z, so is underflow, so dec the msb
    
    	decfsz bres_mid,f		        ; dec the mid byte (subtract 256)
    	goto int_exit			  ; nz, so definitely not one second yet.
    	;------------------------
    	tstf bres_hi			  ; test hi for zero too
    	skpz					  ; z = both hi and mid are zero, is one second!
    	goto int_exit			  ; nz, so not one second yet.
    	movlw 0x0F			        ; get msb value 
    	movwf bres_hi			  ; load in msb
    
    	movlw 0x42			        ; get mid value
    	movwf bres_mid			  ; load in mid
    
    	movlw 0x40			        ; lsb value to add
    	addwf bres_lo,f		        ; add it to the remainder already in lsb
    	skpnc				        ; nc = no overflow, so mid is still ok
    
    	incf bres_mid,f		        ; c, so lsb overflowed, so inc mid
    						  ; now we do the "event" that we do every one second.
    
    						  ; Note! for this example we toggle a led, which
    						  ; will give a flashing led which is on for a second
    						  ; and off for a second.
    						  ; Add your own code here for your one second event
    
    						  ; Note! My led is on porta,3
    						  ; your led may be on a different pin.
    					
      movlw b'00000001'		        ; mask for bit 3
      xorwf tick,f			        ; toggle PORTA,bit3 (toggle the led)
    						
    int_exit
    	INT_RETURN
    ENDASM
    Last edited by fratello; - 27th January 2011 at 15:11.

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    This is my solution. Maybe not correct, but...accuracy is VERY good !
    I read the sensors (each) twice in a minute ; i add the timex variable, for increase 'the duration' of seconds when PIC read sensors, in step of 200 us. From various tests (many guys from one romanian electronics forum) , with 800 us the clock run correct !
    Every advice it's wellcome !
    Code:
    	if seconds=20 or seconds=50 then              'read first DS18B20
    		intcon.7=0
    		gosub temp_1
    			for i=1 to timpx
                      pauseus 200
    			next i
    		intcon.7=1
    	endif
    	if seconds=25 or seconds=55 then              'read second DS18B20
    		intcon.7=0
    		gosub temp_2
    			for i=1 to timpx
    			pauseus 200
    			next i
    		intcon.7=1
    	endif

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