Bug report: Ice Tube

Tick Tock Clock Kits

Moderators: adafruit_support_bill, adafruit

Bug report: Ice Tube

Postby mkwired » Tue Aug 25, 2009 1:47 pm

The expression "wait+ms" can overflow and this case isn't being handled. The function "delayms" can return without waiting long enough.

Code: Select all
volatile uint16_t milliseconds = 0;
void delayms(uint16_t ms) {
  uint16_t wait;
  sei();
  wait = milliseconds;
  while (milliseconds < (wait+ms));
}

// called @ (F_CPU/256) = ~30khz (31.25 khz)
SIGNAL (SIG_OUTPUT_COMPARE0A) {
// ...
  milliseconds++;
// ...
}
mkwired
 
Posts: 7
Joined: Tue Aug 25, 2009 1:40 pm

Re: Bug report: Ice Tube

Postby adafruit » Wed Aug 26, 2009 10:31 am

oh right. yeah luckily delayms is not a precision function -at all- and its not so bad if it fails but i'll fix it ;)

change it to this:
Code: Select all
// We have a non-blocking delay function, milliseconds is updated by
// an interrupt
volatile uint16_t milliseconds = 0;
void delayms(uint16_t ms) {
  sei();

  milliseconds = 0;
  while (milliseconds < ms);
}
User avatar
adafruit
 
Posts: 10489
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Bug report: Ice Tube

Postby madworm_de » Wed Aug 26, 2009 4:49 pm

I'll just hijack this thread, as the title applies to my cause as well.

I've poked around inside the clock's firmware available for download on the 'make' site a bit.

a)

It seems to me the "wakeup()" function is never called at all and the going back to normal stuff is handled inside main() already. If the comparator bit indicates a loss of power it calls "gosleep()", if not it activates or re-activates all normal functions there.

This doesn't break the clock, but the wakeup() function should be marked as "unused" if you keep it in there for reference or educational purpose.

b)

it would be nice to add a comment to the hold-a-button checking routine to go and look at the other ISR that ticks every 1s.

there's some code like

Code: Select all
while(buttonhold) {
...
}


and that variable is decreased inside the other ISR. At first glance that code would never exit the while loop if you keep the button pressed.
NO LARDO CHIPS
User avatar
madworm_de
 
Posts: 99
Joined: Mon Jun 09, 2008 5:56 am

Re: Bug report: Ice Tube

Postby adafruit » Wed Aug 26, 2009 8:46 pm

oh yah, actually i made a few new mods to the firmware since last uploading
but yes wakeup() was taken out when the WDT was put in
the code needs a little more commenting as well. but theres a lot of it and i did my best for now :)
im still stalking one more annoying rare bug that causes the clock to not restore the proper time on power loss. its not a terrible bug but its annoying and happens once in a while. grr!
User avatar
adafruit
 
Posts: 10489
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Bug report: Ice Tube

Postby mkwired » Wed Aug 26, 2009 9:35 pm

I've started to modify the code to make it easier for me to follow the interactions between the "logical" blocks of the firmware. I might totally refactor the code to use a state machine so there's no need to sleep inside an ISR. I might have to buy one of these clocks to see if my modifications work. :D
mkwired
 
Posts: 7
Joined: Tue Aug 25, 2009 1:40 pm


Return to Clocks

Who is online

Users browsing this forum: No registered users and 1 guest

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]