Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ARM?? Cortex?? M4 Cookbook

You're reading from  ARM?? Cortex?? M4 Cookbook

Product type Book
Published in Mar 2016
Publisher Packt
ISBN-13 9781782176503
Pages 296 pages
Edition 1st Edition
Languages
Author (1):
Dr. Mark Fisher Dr. Mark Fisher
Profile icon Dr. Mark Fisher
Toc

Table of Contents (16) Chapters close

ARM Cortex M4 Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
A Practical Introduction to ARM CORTEX C Language Programming Programming I/O Assembly Language Programming Data Conversion Multimedia Support Real-Time Signal Processing Real-Time Embedded Systems Embedded Toolchain Index

Using timers to create a digital clock


A digital clock application provides a good platform to illustrate the components that we discussed in this chapter. We'll use PuTTY to allow the user to set the time and then call HAL_GetTick () to provide a time-base for our digital clock that is displayed on the GLCD. We'll call this recipe ticToc_c3v0.

How to do it…

Follow the following steps to create a digital clock:

  1. Create a new folder for the ticToc_c3v0 recipe and, within it, a new project (ticToc) and use the RTE manager to select board support for Graphic LCD.

  2. Copy the retarget.c, serial.c and serial.h files to the project folder and add them to the project.

  3. Define a new type (time_t) in the ticToc.h header file. Please note that we could declare each variable (hours, minutes, seconds, and so on) as separate unsigned integers, but it is better practice to group them together as a structured type named time_t:

    #ifndef __TICTOC_H
    #define __TICTOC_H
    
    typedef struct {      /* structure of the clock...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime