View previous topic :: View next topic |
Author |
Message |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
PIC18f4620 interrupts. |
Posted: Thu Jan 05, 2012 3:13 pm |
|
|
Hello!
I am using a PIC18f4620's timer3 like this:
Code: |
setup_timer_3(T3_INTERNAL | T3_DIV_BY_1);
enable_interrupts(INT_TIMER3);
enable_interrupts(GLOBAL);
|
This should cause an interrupt every 8,192mS with 32MHz clock. Right?
Look at my timer3 ISR:
Code: |
#INT_TIMER3
void isr(){
output_high(PIN_E0);
delay_ms(1);
output_low(PIN_E0);
}
|
This is just to check at the oscilloscope that the interrupt took place.
While waiting for the interrupt, I have this loop:
Code: |
while(1){
delay_ms(500);
}
|
Now, I noticed that the interrupts do not occur while in the "delay_ms(500); "
Is this possible?
Are interrupts disabled during delay routines?
Thanks! _________________ George. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jan 05, 2012 3:20 pm |
|
|
how can you tell clock is 32mhz ?
i suggest a TOGGLE of the pin
HINT - lose the delay in it as well-
post your CODE and compiler version
then we can talk
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 05, 2012 3:25 pm |
|
|
Various people will tell you not to do it, but setting that aside, here is a
way to solve that problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=38151
Edit to Asmboy. It's obvious he is just doing it for testing purposes. |
|
|
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Thu Jan 05, 2012 3:34 pm |
|
|
Quote: |
how can you tell clock is 32mhz ?
|
The 1ms delay is 1mS in the oscilloscope. Need more proof?
PCM programmer, I saw your solution but I wonder what is the official CCS solution about this?
It is not right to disable interrupts...
Am I doing something wrong?
compiler version 4.093 _________________ George. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 05, 2012 3:55 pm |
|
|
It is correct if your library code is not re-entrant and you want to avoid
having the user's program crash. So that's why CCS did it.
Look in the interrupts section of the CCS faq. They have some articles
on this topic:
http://www.ccsinfo.com/faq.php |
|
|
|