PDA

View Full Version : Strange behavior while detecting external pulses


ins
08-03-2010, 07:02 AM
Hi,

I use a PAN4561 Module for a sleepy Smart Metering application.
The calling of the sleep procedure is located in a 100ms timer. I enable the wake-up functionality for the used pins and go to sleep (0,0). Before I go to sleep I switch a LED off, that is turned on after waking up.

The handling of the the external pulses is located in a HOCK_GPIN procedure.

If I tried to use it in this way, the LED is flashing, but HOCK_GPIN procedure was not called. If I commented the call of sleep (0,0) out, the LED is not flashing any more (permanently on) but the external pulses are detected an proceed.

Does any one has a explanation for this strange behavior?

Best,
ins

ins
08-03-2010, 07:09 AM
def every100ms():
gotoSleep()def gotoSleep():

wakeupOn(GPIO_6, True, False)
wakeupOn(GPIO_9, True, False)
wakeupOn(GPIO_10, True, False)

setPinPullup(GPIO_6, True)
setPinPullup(GPIO_9, True)
setPinPullup(GPIO_10, True)

writePin(GPIO_1, True)

sleep(0, 0)

writePin(GPIO_1, False)@setHook(HOOK_GPIN)
def pinEvent(pinNum, isSet):

if (pinNum == GPIO_6):
#...

if (pinNum == GPIO_9):
#...

if (pinNum == GPIO_10):
#...

gre7g
08-03-2010, 08:09 AM
What sort of signaling is waking up the processor? Is it a short pulse or a long one?

Gre7g

ins
08-03-2010, 09:11 AM
A short one.

ins

gre7g
08-03-2010, 09:20 AM
By default, monitorPin() only checks the pin states ten times a second. If your pulse is short, you could miss it entirely. You can use setRate() to increase how often the pin states are tested.

Also, keep in mind that there is some reaction time that varies from model to model (RF100, RF200, RF300). Refer to the Snap reference manual to see how long it takes the chip you're using to emerge from sleep.

Regardless, what you probably want to do is not use monitorPin() at all. Put your code that handle wake-up immediately after the sleep command.

After all, execution stops completely on sleep(0,0) and will begin again on the following command once the processor wakes. Read the pin states then and see what woke you up before the pulse goes away.

ins
08-04-2010, 08:26 AM
hi gre7g,
thx a lot for your hints. I will give it a try...

Best,
ins