CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18f4620 interrupts.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
georpo



Joined: 18 Nov 2008
Posts: 281
Location: Athens, Greece.

View user's profile Send private message

PIC18f4620 interrupts.
PostPosted: Thu Jan 05, 2012 3:13 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Jan 05, 2012 3:20 pm     Reply with quote

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

Very Happy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 3:25 pm     Reply with quote

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.

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 3:34 pm     Reply with quote

Quote:

how can you tell clock is 32mhz ?


The 1ms delay is 1mS in the oscilloscope. Need more proof? Laughing

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

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 3:55 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group