-->
Page 1 of 1

Why does this code cause a reboot?

PostPosted: Sun Nov 29, 2015 11:14 am
by Trickuncle
This code works:

Code: Select all    while 1 do
    gpio.write(3, gpio.HIGH)
    tmr.delay(1000000) -- wait 1,000,000 us = 1 second
    gpio.write(3, gpio.LOW)
    tmr.delay(1000000) -- wait 1,000,000 us = 1 second
    end


But if I change the delays to 100k from 1M, it runs for a few seconds and then reboots.
Any ideas why?

Re: Why does this code cause a reboot?

PostPosted: Sun Nov 29, 2015 7:25 pm
by Trickuncle
Further testing...
Changing the delay from 1million to 900,000 reboots also
Changing the delay from 1 million to two calls of 500,000 each reboots.
There must be some way to write code for this beast without requiring *ONE SECOND* delays in the main loop...

Thanks to anyone who can tell me what I'm doing wrong!!!

Re: Why does this code cause a reboot?

PostPosted: Sun Nov 29, 2015 7:38 pm
by Barnabybear
Hi, take the while out.

Re: Why does this code cause a reboot?

PostPosted: Sun Nov 29, 2015 11:08 pm
by Trickuncle
Thanks for the reply!

That works! I guess the while loop tied up the system? I've replaced the delay code with a tmr.alarm - this is working great!

Thanks for the help!!