If I create a “fast” timer based on functioncallback (wanted to detect some zerocross) - 0.02sec - the IMP’s timer goes wild (starting to go faster). Can be reproduced with the april too - used a sparkfun one after I noticed the issue with my prototypes. It’s not permitted to use callbacks with periods <1sec?
The code to reproduce it:
// Clock test
imp.configure(“Clock tester”,[],[]);
server.log("=======>Clock tester starting …");
server.log(“IMPId:”+hardware.getimpeeid());
imp_sel1 <- hardware.pin1;
imp_sel1.configure(DIGITAL_OUT);
imp_sel2 <- hardware.pin8;
imp_sel2.configure(DIGITAL_OUT);
imp_sel1.write(1);imp_sel2.write(1);//backup
//imp_sel1.write(0);imp_sel2.write(0);//no backup
function upsZeroCrossChecker()
{
imp.wakeup(0.02, upsZeroCrossChecker);
}
function main()
{
imp.wakeup(5, main);
server.log(format(“MAIN mem=%d sec=%d”,imp.getmemoryfree(),clock()));
}
main();
upsZeroCrossChecker();
The result with and without the imp.wakeup(0.02, upsZeroCrossChecker); line is below. It can be clearly seen that the IMP counts 5 second in both cases but in the log in one case is coming in every 3 (sometimes 4) second and in the second case comes in every 5-6 second as it should. The result is the same with blinking a led but this version is easier to check for You guys. It’s understandable if that 3 second pops up rare because of net congestion but than it should be followed by longer times but it doesn’t - the 5 second becomes shorter for the imp if the 0.02sec timer is running …
With upsZeroCrossChecker
Tuesday, January 08, 2013 13:06:21: MAIN mem=61956 sec=439
Tuesday, January 08, 2013 13:06:24: MAIN mem=61956 sec=444
Tuesday, January 08, 2013 13:06:27: MAIN mem=61956 sec=449
Tuesday, January 08, 2013 13:06:30: MAIN mem=61956 sec=454
Tuesday, January 08, 2013 13:06:33: MAIN mem=61956 sec=459
Tuesday, January 08, 2013 13:06:36: MAIN mem=61956 sec=464
Tuesday, January 08, 2013 13:06:39: MAIN mem=61956 sec=469
Tuesday, January 08, 2013 13:06:42: MAIN mem=61956 sec=474
Tuesday, January 08, 2013 13:06:45: MAIN mem=61956 sec=479
Tuesday, January 08, 2013 13:06:48: MAIN mem=61956 sec=484
Tuesday, January 08, 2013 13:06:51: MAIN mem=61956 sec=489
Tuesday, January 08, 2013 13:06:54: MAIN mem=61956 sec=494
Tuesday, January 08, 2013 13:06:57: MAIN mem=61956 sec=499
Tuesday, January 08, 2013 13:07:00: MAIN mem=61956 sec=504
Without upsZeroCrossChecker
Tuesday, January 08, 2013 13:07:52: MAIN mem=62088 sec=567
Tuesday, January 08, 2013 13:07:58: MAIN mem=62088 sec=572
Tuesday, January 08, 2013 13:08:03: MAIN mem=62088 sec=577
Tuesday, January 08, 2013 13:08:09: MAIN mem=62088 sec=582
Tuesday, January 08, 2013 13:08:14: MAIN mem=62084 sec=587
Tuesday, January 08, 2013 13:08:19: MAIN mem=62088 sec=592
Tuesday, January 08, 2013 13:08:24: MAIN mem=62088 sec=597
Tuesday, January 08, 2013 13:08:30: MAIN mem=62088 sec=602
Tuesday, January 08, 2013 13:08:35: MAIN mem=62088 sec=607
Tuesday, January 08, 2013 13:08:40: MAIN mem=62088 sec=612
Tuesday, January 08, 2013 13:08:46: MAIN mem=62088 sec=617
Tuesday, January 08, 2013 13:08:51: MAIN mem=62088 sec=622
Tuesday, January 08, 2013 13:08:56: MAIN mem=62088 sec=627
Tuesday, January 08, 2013 13:09:02: MAIN mem=62088 sec=632
Tuesday, January 08, 2013 13:09:07: MAIN mem=62088 sec=637
Tuesday, January 08, 2013 13:09:12: MAIN mem=62088 sec=642
Tuesday, January 08, 2013 13:09:18: MAIN mem=62088 sec=647
Tuesday, January 08, 2013 13:09:23: MAIN mem=62088 sec=652
Tuesday, January 08, 2013 13:09:28: MAIN mem=62088 sec=657