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
Posted: Tue Jun 08, 2010 12:56 pm
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.
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