This is a free download!
The Arduino platform is not only the ideal solution for the hobbyist due to its low price and ease of programming; it is also a great tool for professionals who are looking for quick prototyping.
This application note will address the particular topic of timer control for the Arduino Due.
The Arduino platform does provide library functions dedicated to timers, and they cover all Arduino boards, including the Arduino Due. However, the Due takes up a unique position in the Arduino product line of processors.
It is, after all, the first ARM-based Arduino development board, which accounts for special considerations compared to the standard, ATmega-driven boards. The ARM Cortex-M3 processor’s versatility opens the door to more sophisticated applications, including timer programming.
A timer is a clock that controls the sequence of an event while counting in fixed intervals of time. A timer is used for producing precise time delay. Secondly, it can be used to repeat or initiate an action after/at a known period of time. Most processors have timers incorporated on the chip. They not only generate time delays but they can also be used as counters.
Source: EngineersGarage – https://www.engineersgarage.com/definitions/what-is-timer
This definition of timers is essential because this document is not about timekeeping, i.e., managing the date and time of the day.
The application of timers can be as simple as a blinking LED or as complex as detecting an interruption in a serial data communication.
Not all applications will require complex timing algorithms, but it is beneficial to have a set of timer functions that integrate easily without the need for a significant learning curve. My timer library includes functions to initialize, load, start and stop a timer, and check the timer count and status.
As I mentioned previously, the Arduino platform already provides library functions dedicated to timers, and there are more samples available through the Arduino Playground. However, my focus was on increased precision and adaptability to other hardware platforms, e.g., using the same concept on an NXP LPC17xx processor.
Last but not least, the following assumes some basic knowledge of embedded programming with the Arduino platform. Should that not be the case, please refer to the literature appendix, especially the books written by Simon Monk. Be assured that the learning curve is minimal.
My point is, I will not engage in repeating topics that have already been covered extensively by others, but I will reference resources where necessary.
Download the Application Note
The information provided in this document is provided "as is" without warranty of any kind. Copperhill Technologies Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Copperhill Technologies Corporation be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Copperhill Technologies Corporation or its suppliers have been advised of the possibility of such damages.
Download the Code Sample
The Arduino Due Timer Control sample code (sketch) is a free download (zip file) and it can be downloaded here:
Neither the author nor the publisher are responsible for technical support of any project you derive from or add to the sample code. The Arduino Due Timer Control sketch is a free software; you can redistribute it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. With downloading this programming sample, you confirm that you have read and agree with these terms and conditions.
by Simon Monk
This thoroughly updated guide shows, step-by-step, how to quickly program all Arduino models. Programming Arduino: Getting Started with Sketches - Second Edition, features easy-to-follow explanations, fun examples, and downloadable sample programs.
Discover how to write basic sketches, use Arduino’s modified C language, store data, and interface with the Web. You will also get hands-on coverage of C++, library writing, and programming Arduino for the Internet of Things. No prior programming experience is required!
by Simon Monk
In this practical guide, electronics guru Simon Monk takes you under the hood of Arduino and reveals professional programming secrets. Featuring coverage of the Arduino Uno, Leonardo, and Due boards, Programming Arduino Next Steps: Going Further with Sketches shows you how to use interrupts, manage memory, program for the Internet, maximize serial communications, perform digital signal processing, and much more.
All of the 75+ example sketches featured in the book are available for download.
by Joseph Yiu
This new edition has been fully revised and updated to include extensive information on the ARM Cortex-M4 processor, providing a complete up-to-date guide to both Cortex-M3 and Cortex-M4 processors, and which enables migration from various processor architectures to the exciting world of the Cortex-M3 and M4.
This book presents the background of the ARM architecture and outlines the features of the processors such as the instruction set, interrupt-handling and also demonstrates how to program and utilize the advanced features available such as the Memory Protection Unit (MPU).
Chapters on getting started with IAR, Keil, gcc and CooCox CoIDE tools help beginners develop program codes. Coverage also includes the important areas of software development such as using the low power features, handling information input/output, mixed language projects with assembly and C, and other advanced topics.
Leverage the power of an ARM Cortex M3 32-bit processing capability combined with a dual CAN Bus interface to create your next CAN Bus or SAE J1939 application or prototype. By combining our dual CAN port interface, the Arduino DUE microcontroller, an OBD2 or SAE J1939 cable, and open-source software libraries, you are ready to go with a powerful turn-key Arduino-based dual CAN bus solution.
Use the vast resources of Arduino software (sketches) and hardware components (shields) to create your CAN Bus, OBD2, or SAE J1939 application.