Using the MsTimer2 library on AT90USB646

In order to use the Arduino MsTimer2 library on AT90USB646 microcontroller you have to minimally modify the source code of the library. First, download the library, unpack it into the “libraries” directory of your Arduino installation (it’s a subdir of “hardware”) and open the file MsTimer2.cpp. Find all the lines that match the following:

#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)

and change it to

#if defined (__AVR_AT90USB646__) || (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)

Thus, the AVRUSB646 target has been added to the library. Save the file, delete the old MsTimer2.o if exists (it can be found in the same directory) and enjoy the fruits.


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *