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

Illustrating machine storage classes


This recipe illustrates a version of addTwoNums that uses the machine storage classes, int32_t and uint8_t. We explain why it is advantageous for embedded applications to define and use these as opposed to the primitive types that are provided by the C language.

How to do it…

To define and use machine storage classes, please follow the outlined steps:

  1. Create a new folder named addTwoNums_v2 by cloning the previous project.

  2. Copy the addTwoNums.c file from the previous recipe to the folder and modify it as follows:

    int main (void) {
      
      int32_t input;
      uint8_t num1, num2, res;
    
      HAL_Init ();   /* Init Hardware Abstraction Layer */
      SystemClock_Config ();           /* Config Clocks */
    
      SER_Init();
      
        for (;;) {                      /* Loop forever */
        printf("Enter First Number: ");
        scanf("%d", &input);
        num1 = (uint8_t) input;
        printf("Enter Second Number: ");
        scanf("%d", &input);
        num2 = (uint8_t) input;
        res = num1...
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