Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 3567 Microcontrollers Dr. Gregg J Chapman

Similar presentations


Presentation on theme: "ECE 3567 Microcontrollers Dr. Gregg J Chapman"— Presentation transcript:

1 ECE 3567 Microcontrollers Dr. Gregg J Chapman
Office hours: Thursday 11:15 AM - 2:15 PM, or by appointment Caldwell Lab, Room 249 Lab Monitors: Zabrina Orrecchio, Ryan Ruch, Yifan Wu

2 https://u.osu.edu/ece3567labs
ECE 3567 Microcontrollers Material: Lab instructions are presented in class Additional material is available at: Students are not required to purchase anything. All lab equipment will be provided. Grading: Quizzes 30% No quiz the first week. There are 6 quizzes each work 5% Checkpoints 20% Progress Reports 30% Due on the Friday following the week of the lab. There are 5 progress reports each worth 4% Final Report 20% Due on Friday of the week after the final lab. No lab grades are dropped

3 ECE 3567 Microcontrollers Laboratory Topics:
Lab 1 (2/15) – A review of C, Microcontroller architecture, Code Composure Studio Lab 2 (2/22) – General Purpose IO, The LCD, Command Structure Lab 3 (3/1) – Timers and PWM Lab 4 (3/8) – Communications and the UART SPRING BREAK (3/16) Lab 5 (3/22) –The Analog to Digital Converter Lab 6 (3/29) – The Temperature Sensor Lab 7 (4/5) – The RC Voltage Controller Lab 8 (4/12) – The Final Project

4 A Review of C Programming
ECE 3567 Microcontrollers A Review of C Programming (with notes on Embedded C)

5 C Standards ANSI C – (1972), Dennis M. Ritchie, Bell Labs. One of the Authors of the original book “The C Programming Language”. American National Standards Institute defined the C Language officially in 1989. ISO 9899 (International Organization of Standards) has assumed responsibility for the “official” version of “C”. The ISO 9899 version is arrogantly referred to as “The C Language”, and ISO claims to “own” the language. ISO 9899 demagogues have released two newer versions of “C”, in 1999 and Both have additional keywords which are generally USELESS in an embedded environment or for portability. Most C compliers have been upgraded to C99 but not C11. The original 32 keywords defined in 1989 are sufficient for embedded design, and will make the code portable across more platforms than either C99 or C11.

6 ANSI C Keywords

7 C Conditional Statements

8 C Loop Control

9 C Loop Statements

10 C – Variable Types

11 C – Floating Point Variables

12 C Storage Classes auto (default) – The variable is only defined in the current function. register – The variable is still local, but is not stored in memory, it is stored in a register of the MCU, making access VERY FAST. volatile – A global variable that can be changed by multiple processes in the operating environment. static – This is still a local variable! It’s value remains intact between accesses of the function in which it is defined and used. extern – Usually in header files, this means that the variable definition exists in another files. This is not a declaration type. It is a statement that the declaration exists elsewhere. All modules can used the defined variable. volatile – Two or more threads are permitted to change the value of this variable. It is truly global.

13 C – Arithmetic Operators

14 C – Relational Operators

15 C

16 C – Logical Operators

17 C – Bit Operators

18 C – Ternary Operators

19 The ASCII Character Set

20 C – Escape Sequences used in Formatting

21 C Compiler Directives #pragma – Tells the compiler to include something once if it is included in multiple files. #typedef – Defines an alias name #ifdef (or #ifdef) – Conditional compilation based on a definition #endif #define – Declares a constant and may or may not give it a value. Can also be used to label a macro. #include – A compiler directive that adds the contents of an external file to the current file definition.

22 Embedded C It is C, but does NOT conform to common software practice due to all the # compiler directives and header files. It relies extensively on #defines and #typedefs located in included HEADER files (.h) in order to make low level manipulation of the hardware much easier than assembly language. NOTE: this also makes the C program look “funny” to software engineers. It is hardware dependent, particularly constant and variable sizes. If unsure of a constant or variable size use sizeof() to find out!

23 Embedded C REAL WORLD ADVICE ON EMBEDDED PROGRAMMING:
NEVER write from the ground up. COPY and MODIFY working source code. Be careful of COPYWRITES. ALWAYS use the HEADER files from the MCU manufacturer. Use an Evaluation Board for development if possible. If not, these usually come with schematics that give you a good idea of what is required to get your MCU “off the ground”. UNDERSTAND THE HARDWARE! Read the Datasheet, at least for the modules that you are using. Initialization is MORE THAN HALF of the project. Write the initialization for each MCU sub-device (module) as a SEPARATE function.

24 Embedded C REAL WORLD ADVICE ON EMBEDDED PROGRAMMING:
The main.c should consist of the following, in this order: A DETAILED DESCRIPTION in comment format #includes (esp. xxx.h files) and compiler directives Calls to INITIALIZATION FUNCTIONS The MAIN LOOP consisting almost entirely of function calls Interrupt Service Routines if applicable

25 NOTE: Code Composure Studio DOES NOT SUPPORT BINARY NUMBERS
Embedded C EXAMPLES: P1OUT = 0x01; Sets bit zero on the output of PORT 1, but clears the other 7 bits. the P1OUT and it’s address are defined in a header file. P1OUT |= BIT0; Bitwise ORs PORT 1 with BIT0 (0x01 or b), setting the LS bit of PORT 1 and preserving the other 7 bits in their original state. P1OUT &= ~BIT0; Bitwise ANDs PORT 1 with NOT BIT0 (0xFE or ), clearing the LS bit of PORT 1 and preserving the other 7 bits in their original state. NOTE: Code Composure Studio DOES NOT SUPPORT BINARY NUMBERS

26 The MSP430FR6989 Microcontroller Architecture
ECE 3567 Microcontrollers The MSP430FR6989 Microcontroller Architecture

27 The MSP430FR6989 Microcontroller Architecture

28 The MSP430FR6989 Microcontroller Architecture

29 ECE 3567 Microcontrollers Code Composer Studio (Version )

30 Code Composer Studio Compile Debug Run Stop

31 ECE 3567 Microcontrollers Code Composer Studio (Version )

32 The Controller Project


Download ppt "ECE 3567 Microcontrollers Dr. Gregg J Chapman"

Similar presentations


Ads by Google