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
Bookmarks