Issue – Driver freezing

///Issue – Driver freezing

Issue – Driver freezing

The Issue

When initially turned on the driver would happily receive commands and act on them. If the device transmitting the commands was interrupted then restarted it would cause the driver to freeze. The issue was reliably replicated.

The Cause

Using an array of serial messages to debug the code it was apparent the issue was the driver getting stuck in a loop governed by a “millis” function. The millis functions are part of the radio library for the Alpha modules being used. It is a usefully utility function which provides easy timing ability based around the atmel’s own millis timer.  The timer function can be used in two states, a one-shot state where the timer is set and polled till it fires, then it does NOT re-fire. The second state just keeps resetting itself after each firing.

The technical reason behind this was not clear and with time being a limiting factor, when a valid work around was found the issue was marked solved. It is my belief that it was due to the rapid jumping between the use of two instances of this timer, one for fading and a second for the radio.

The Solution

Once the timer was identified as the culprit it was not long before i switched it from the automatically re-setting state it was being used in to a one shot setup. This instantaneously solved the problem and it had yet to re-occur.

The current code:

void ClightiveDrvr::outUpdate() //Call update to push next array out and updates current array<br />
{<br />
bool fadeincomplete = 1;<br />
uint16_t stepN = 1;<br />
while(fadeincomplete)<br />
{<br />
if(fadeInterval.poll()){ // POLL THE TIMER (This was the sticking point)<br />
fadeincomplete = 0;<br />
for( uint8_t chan = 0 ; chan &amp;lt; 16 ; chan++ ){<br />
if( stepcount[chan] &amp;gt; 0 )<br />
{<br />
if( --stepcount[chan] == 0){<br />
currentval[chan] = finalval[chan];<br />
stepFade( chan, finalval[chan]);<br />
}<br />
else<br />
stepFade( chan, int( currentval[chan] + (stepN * stepsize[chan]) ) );</p>
<p>}<br />
fadeincomplete += stepcount[chan];<br />
}<br />
Tlc.update();<br />
stepN++;<br />
}<br />
}<br />

By |2015-01-13T23:46:13+00:00February 19th, 2011|Lightive Project|0 Comments

About the Author:

A PhD in Electronic Engineering. A love for photography ( An interest in tinkering, electronics and design. (

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.