thx for scalerobotics's kindly reply =)
by the way,after i read thru the website,i still cant get the point. Perhaps i do not have the basic knowledge about something like option_reg or t1con. i think i have to read the basic 1st.
=(
thx for scalerobotics's kindly reply =)
by the way,after i read thru the website,i still cant get the point. Perhaps i do not have the basic knowledge about something like option_reg or t1con. i think i have to read the basic 1st.
=(
ASM interrupts are good, Darrel's instantaneous ones are best...
But for starters look at ON INTERRUPT in the PBP manual and INTCON in the chips data sheet.
BTW, what chip are you playing with?
Dave
Always wear safety glasses while programming.
sorry guys, im really cant understand what darrel did, from this page http://darreltaylor.com/DT_INTS-14/elapsed.html
how the program know when start button is interrupted??
in wat condition the program will
gosub starttime and gosub resettime??
Hi, reik
Your scenario reminds me a "Thunderstrike distance measurer" ... ( sorry for the Tool name ... I am French ...)
so, if I understand it right ...the time between two interrupts could be many seconds ... ( 4 in your example ).
Consider a Pic Timer itself ( Timer1 ...i.e.) can count up to 0.52s @ 4Mhz clock ... so, you have to use an extra counter that will count Timer 1 Overflows.
your time will be ( 0.52s x nb of overflows ) + ( Timer1 x 8µs )
distance will be ... 330 ( or SQR ( 1.3*287*(Temp+273.15)) ... x count (s)
see Here for Timer calculations help :
http://pictimer.picbingo.com/index.php
BUT, you first have to open your pic datasheet to learn about the Timer modules and CCP module ( capture mode ) use.
Darrel's Interrupts just are the easy tool to drive the interrupts ... but it is you to configure what happens during the interrupts ...
The process is the same for pulse duration measuring, Rpm meters, shotshells speed measuring ...
Just need to know the maximum time between interrupts ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
HI everyone, although im nt understand the code, but im trying to modify the code to my desire code. Hope to pros 1 can help me to debug =)
'* Name : Elapsed_INT.bas
; syntax = Handler IntSource, Label, Type, ResetFlag?
DEFINE Elapsed_Handler TMR1_INT, _ClockCount, PBP, yes
Ticks var word ' 1/100th of a second (10ms) <--- how to change to 1ms ?
BitSave VAR BIT
'''''Goto OverElapsed <---- ????
' ------------------------------------------------------------------------------
Asm
IF OSC == 4 ; Constants for 100hz interrupt from Timer1
TimerConst = 0D8F7h ; Executed at compile time only
EndIF
If OSC == 8
TimerConst = 0B1E7h
EndIF
If OSC == 10
TimerConst = 09E5Fh
EndIF
If OSC == 16
TimerConst = 063C7h
EndIF
If OSC == 20
TimerConst = 03CB7h
EndIF
; ----------------- ADD TimerConst to TMR1H:TMR1L
ADD2_TIMER macro
CHK?RP T1CON
BCF T1CON,TMR1ON ; Turn off timer
MOVLW LOW(TimerConst) ; 1
ADDWF TMR1L,F ; 1 ; reload timer with correct value
BTFSC STATUS,C ; 1/2
INCF TMR1H,F ; 1
MOVLW HIGH(TimerConst) ; 1
ADDWF TMR1H,F ; 1
endm
; ----------------- ADD TimerConst to TMR1H:TMR1L and restart TIMER1 ----------
RELOAD_TIMER macro
ADD2_TIMER
BSF T1CON,TMR1ON ; 1 ; Turn TIMER1 back on
endm
; ----------------- Load TimerConst into TMR1H:TMR1L --------------------------
LOAD_TIMER macro
MOVE?CT 0, T1CON,0
MOVE?CB 0, TMR1L
MOVE?CB 0, TMR1H
ADD2_TIMER
endm
EndAsm
' ------[ This is the Interrupt Handler ]---------------------------------------
ClockCount:
@ RELOAD_TIMER ; Reload TIMER1
Ticks = Ticks + 1
if Ticks = 65535 then
Ticks = 0
endif
@ INT_RETURN ; Restore context and return from interrupt
'-----====[ END OF TMR1 Interrupt Handler ]====---------------------------------
interrupt:
'
' Restart counting
Tsensor = ticks ; Save the timing between sensor pass through
BitSave = T1CON.0 ; Save TMR1ON bit
@ LOAD_TIMER ; Load TimerConst
T1CON.0 = BitSave ; Restore TMR1ON bit
Ticks = 0
return
define LOADER_USED 1
define OSC 20
include "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
INCLUDE "Elapsed_INT.bas"
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM
T1CON.1 = 0 ; (TMR1CS) Select FOSC/4 Clock Source
T1CON.3 = 0 ; (T1OSCEN) Disable External Oscillator
T1CON.0 = 1 ; (TMR1ON) Start TIMER1
Main:
LCDout $FE,$C0, de5 ticks
GOTO Main
but i really dont understand, i have the INTERRUPT: subroutine, but how the system knows when my sensor is falling edge, it will getting interrupt and jump to this subroutine??
Bookmarks