Test&debug your embedded C module with Excel and Visual Studio

For a while now I’ve had a mental itch that needed to be scratched and finally found some time to do something about it. I had a function called rtc_date_time_to_sec_since_y2k() to convert date&time to seconds since Y2K, but I did not have one in the reverse direction… until now 🙂

Here is the best solution that I could find, but I wanted something simpler that I understood well and it only needed to work from 2000 to 2099 (I’m a firm believer in the KISS principle).

First I used an Excel Spreadsheet to have a broad overview of the algorithm:

Finally I created a test project for my RTC C module in the free (as in beer) Visual Studio Community Edition 2017. It tests the whole space (every second from 2000-01-01 00:00:00 to 2099-12-31 23:59:59) and took only 10 minutes on an Intel Core i7-6700 CPU @ 3.40GHz. Running the same test on an 8-bit Atmel AVR @ 7.37 MHz would take (a projected) 25 days!

I use a “defines.h“, “compiler.h” and “pgm_P.h” to make my embedded C modules portable.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.