Tuesday, June 28, 2011

Found and fixed bug in AVR code

So thanks to Teo and Warren's super don testing, I was able to find and fix a bug in my code. The bug was because I had a stray "int" in the code which is compiled as a signed 16-bit number for AVR but is a signed 32-bit number for every other platform I support. The signed 16-bit number turned out to not have enough precision which was causing problems with the VBI once the frame number got over approximately 16,384 (because the field number would exceed 32,767 and wrap around).

Unfortunately, this is not a defect that my unit tests (when run on x86) would have caught because it only existed on the AVR. So I have changed all data types in that code to be explicit so they will be the same size on every platform. That seems like the best compromise I can do right now.

Here is Teo's latest video showing off the improved code:

No comments:

Post a Comment