cavemoa / Feather-M0-Adalogger

Code for Feather M0 Adalogger
MIT License
26 stars 7 forks source link

32 bit counter should be used for millis counter #3

Open Colin-at-511100471793 opened 4 years ago

Colin-at-511100471793 commented 4 years ago

hi all, I was using this board to log something at a few hundred hz and my coworker wanted to make sure the timing was accurate with the millis counter.. so I dropped in the millis count at every sample only to discover that we were losing time?? anyways I looked at the implementation which is not what I thought it was. the M0 is a 32 bit mcu and has one (or several) 32 bit counters. I assumed that the millis() function would just read off one of the count and divide it by some number. This is the way the counter is implemented in other mcu's (I'm thinking of the sparkfun artemis arduino as example). This however, uses an 8 bit count from the original 328 arduino, so it services an interrupt every millisecond(and I was blocking this isr).

it took a while to convince my coworker that we were not in fact losing time:) (we put some sine waves in and saw that there was no 10ms glitch as the millis count would indicate.)

anyways- long story short is that it seems a little ineficient to service this isr every 1ms when we don't need to. It can also be misleading to people trying to timestamp stuff with it.

Colin-at-511100471793 commented 4 years ago

sorry about that- ignore all that, this is the wrong repo.. I meant to put this in adafruit's samd repo ;)