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 support@ccsinfo.com

Using time base in sleep mode

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



Joined: 02 Jun 2010
Posts: 74

View user's profile Send private message

Using time base in sleep mode
PostPosted: Mon Jun 07, 2010 9:18 pm     Reply with quote

Hi, I am using PIC18F65J90 to calculate frequency using as low power as possible.
I set up the main code to sleep until the interrupt caused by 50Hz external pin interrupt makes 500ms time base.
I then simply multiply the pulse collected (in timer1) by 2 to calculate frequency.
The issue is that the frequency displayed isn't correct (not close at all) and it fluctuates.
I checked the pulse collected during 25 interrupts (25*20=500ms) and it seems to be changing randomly.

The question is that, would external interrupt correctly generate 50Hz interrupt service routine in sleep mode? It seems to work correctly when I turn off the sleep instruction and let the main program poll the ready flag putout by interrupt service routine.

Thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 08, 2010 12:56 pm     Reply with quote

Look at the delay required to wake-up from sleep mode. It's shown in
this diagram in the 18F65J90 data sheet:
Quote:
FIGURE 3-6: TRANSITION TIMING FOR WAKE FROM SLEEP (HSPLL)

It shows that after the interrupt edge occurs, 1024 oscillator clocks
must occur and then 2ms more, if you are using the PLL. This delay
could account for the incorrect timing that you see.
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