View previous topic :: View next topic |
Author |
Message |
sraiderk
Joined: 09 Feb 2005 Posts: 48
|
Check the Flag of Time interrupt in EXTinterrupt use18F27K40 |
Posted: Fri Jan 11, 2019 4:55 am |
|
|
Is it possible to check the flag of Timer0 in EXT interrupt. I mean:
Code: |
#INT_EXT1
void EXT1_isr(void)
{
if (Now_Timer0_interrupted_andwaiting_finish_thisprocess==True)
{
do_something
tTimer0 overflow and waiting
}
else {
do_something
Don't worry about Timer0
}
}
#INT_TIMER0
void TIMER0_isr(void)
{
clear_timer0_interrupt
not important
} |
is there any key or Flag statement for variable in my program that is "Now_Timer0_interrupted_andwaiting_finish_thisprocess" |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Fri Jan 11, 2019 6:27 am |
|
|
Yes, you can read the status of the TMR0IF bit in the INTCON register. While I don't have your PIC, I'll assume it's similar to the 18F46K22 and it can, fairly confident all PICs can.
Just be sure NOT to have some loop withing the ISR, or 'math' or prints.. just set a flag and exit.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Fri Jan 11, 2019 8:11 am |
|
|
Command in CCS, is 'interrupt_active'.
So in your INT_EXT, you can simply use:
if (interrupt_active(INT_TIMER0))
and then execute what you want to do if this interrupt is active.
Remember you will have to clear it. The standard interrupt handler
does this for you, (you are showing a clear in your code - this means it is
being cleared twice - if you want the compiler to not clear it, add 'NOCLEAR'
after the interrupt declaration.
Handling the interrupt yourself, you will need to add the 'clear_interrupt' code. |
|
|
sraiderk
Joined: 09 Feb 2005 Posts: 48
|
|
Posted: Tue Feb 05, 2019 6:15 am |
|
|
Thank you for perfect explanation now and all before.. |
|
|
|