Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can we use 2 interrupts simulataneously in pic micro !

Status
Not open for further replies.

jit_singh_tara

Full Member level 6
Joined
Dec 22, 2006
Messages
325
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Location
Delhi , India
Activity points
4,293
i need to sense rpm in 1 second .

i am using timer0 for 1 second duration, and i need to sense counts in 1 second i.e ext interrupt on portb.0 of pic , how do i manage these two interrupts simultaneously.
 

Hi,
In the INTCON register enable both these interrupts and set the Gobal Interrupt bit. When the interrupt occurs, in the interrupt routine check each flag and execute the appropriate routines if they are set. In the timer interrupt routine when the count reaches one second, read the value of the count in the Ext.Interrupt routine counter and use it for RPM calculation.
Regards,
Laktronics
 
jit_singh_tara said:
i need to sense rpm in 1 second .

i am using timer0 for 1 second duration, and i need to sense counts in 1 second i.e ext interrupt on portb.0 of pic , how do i manage these two interrupts simultaneously.

Are you really wanting RPS at all? If not, then it makes no sense to use 1 second as your base time for the capture.

If you're wanting to get RPM, then it is far easier to use something with a binary relationship to a minute as your timing window. 60sec (for RPM) / 64 = .9375 second. Calculate your cycle timing and set your capture time to that, if you need more use twice that as in 60 sec/32 for 1.875 seconds of capture.

Then just take your count and shift left 6 or 5 times respectively to multiply by 64 or 32 to get RPM. It always pays get a binary relationship to what you really want, then make it where all you have to do is shifts to get the end result. The 60 seconds to a minute relationship is relatively arbitrary in the first place, so there's no need to limit yourself to using seconds if you don't actually need RPS. One time of doing the work ahead will often save even needing a *60 routine..
 
Remember that PIC16F familly have just 1 interrupt vector, and your firmware is responsible to manage routines priority.

+++
 
Hi!
You can use any number of interrupts simultaneously on any PIC but as already mentioned you have to take care of the priority of the interrupts yourself. In PIC microcontrollers whenvever any interrupt is generated the controller simply jumps to the interrupt vector location provided that the global interrupts have been enabled (GIE = 1) and the interrupts of interest are also enabled. You then have to poll the individual interrupt flags to see which one of the enabled interrupts have actually caused the interrupt.
Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top