The issue is that the 16 clock MHz cannot be factored by a power of two to equal 1ms, so a straight clock divider cannot produce a 1ms signal. Timer 0 is an eight bit counter that is fed by the system clock divided by 64. The first issue I had was with how accurate the millisecond clock count is on the Arduino. I was concerned about two things: First, the accuracy of the millis() count, and second, the peculiar rollover behavior of the function. Rob Faduli proposed a method for detecting and handling rollovers in the code, but I was confused about the problem- if it was a straight rollover problem, my code should have worked properly, as modular arithmetic should ignore the momentary overflow. I was concerned about two things: first, the accuracy of the millisecond count, and second, how overflows were handled. However, to complete my current project, I needed to confront this. I knew that there was some nine hour rollover issue when the clock overflows, but had been content to leave it at that. ![]() I had used the millis() function in smaller projects before, but none of them were ever meant to be run for more than a short time. I finally got some time to look into the issue. I recently started an art clock project which actually needed to be run for more than just a few hours, and ran head on into a known issue with the millis() function of the Arduino library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |