calculate the duration(in seconds) between hardware interrupts

Status
Not open for further replies.

niteshtripathi

Member level 3
Joined
Oct 11, 2013
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
429
How to calculate the duration(in seconds) between hardware interrupts received at INT0 and INT1 pins in 8051 MCU with 11.0592 MHz crystal?
 

You can use two timers . Initialize both timers.... keep counting timer till interrupt happens on both pins...as interrupt happens off timers and check the Timer1 & timer 2 values.
 

time = (2^(bit length)-Timer value)*no. of instructions cycles/Freq.
bit length is timer type :- 8 bit or 16 bits
no. of instruction cycles has default value 4 for 8051
timer value is TMRH:TMRLow ..like TMRH is FC and timer low is EA then timer value is TMR=FCEA... convert it into decimal
 

helo

if you have a CCP capture in this 8051 (i only know PIC family)
you can use an ouput
put it ON when Int0 occurs
put it OFF when Int1 occurs
this output connected to CCP1 input (associated to a 16bits timer)
so when Rise edge ON detec : CCP interrupt clear the timer
and when rise edge OFF detect : CCP interupt read the value of CCPR (=timer)

don' t forget to manage overload of timerx (pass over 65536) for big time elapsed.


One qustion:
why are you using 11.0592 MHz crystal value , and not a rounded value as 8 or 16 Mhz?
wich coul give a rouind value for time cycle .
easir to calculate time...
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…