ECE 3567 Microcontrollers Dr. Gregg J Chapman

Slides:



Advertisements
Similar presentations
Syllabus Instructor: Dr. Wesam Ashour
Advertisements

Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
Lab6 – Debug Assembly Language Lab
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Railway Foundation Electronic, Electrical and Processor Engineering.
Ceng 230 Programming with C
Railway Foundation Electronic, Electrical and Processor Engineering.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Modules and Scope Gabriel Hugh Elkaim Spring 2013.
CS102 Introduction to Computer Programming
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
COE Computer Organization & Assembly Language Talal Alkharobi.
The Structure of a C++ Program. Outline 1. Separate Compilation 2. The # Preprocessor 3. Declarations and Definitions 4. Organizing Decls & Defs into.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Chapter 1 – Computing Fundamentals. History of Electronic Computers u First computer –ABC (Atanasoff Berry Computer) at Iowa State U. –1930’s –Solved.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
MICROOCESSORS AND MICROCONTROLLER:
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Introduction. Natural Languages are languages of the Humans These Languages tend to be ambiguous A sentence in natural may not have just one meaning I.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
INC 161 , CPE 100 Computer Programming
History of C and basics of Programming
Michael Rahaim, PhD Candidate Multimedia Communications Lab
Microprocessor and Microcontroller Fundamentals
Microprocessor and Microcontroller Fundamentals
The Machine Model Memory
ECE 103 Engineering Programming Chapter 5 Programming Languages
MODULAR PROGRAMMING Many programs are too large to be developed by one person. programs are routinely developed by teams of programmers The linker program.
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
GC101 Introduction to computers and programs
Microprocessor Systems Design I
Microprocessor Systems Design I
C Language VIVA Questions with Answers
IPCOWALA INSTITUTE OF ENGINEERING & TECHNOLOGY-DHARMAJ
ACOE301: Computer Architecture II Labs
PRA-SYARAT SISTEM MIKROPROSESOR
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
CHAPTER 1: Introduction to Computers and Programming
Introduction to C Programming Language
8051 Programming in C rhussin.
Introduction to Microprocessors and Microcontrollers
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Compiler Construction
Basics of ‘C’.
Fundamentals of Computer Organisation & Architecture
Govt. Polytechnic,Dhangar
Embedded Programming in C
ECE 3567 Microcontroller Lab
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Introduction to Computer Programming
C programming Language
2. Second Step for Learning C++ Programming • Data Type • Char • Float
The C Language: Intro.
Chapter 6 Programming the basic computer
C – Programming Language
Variables in C Topics Naming Variables Declaring Variables
C Language B. DHIVYA 17PCA140 II MCA.
ECE 3567 Microcontrollers Syllabus – Spring 2019
ECE 3567 Microcontrollers Lab
ECE 3567 Microcontrollers Lab
Presentation transcript:

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

https://u.osu.edu/ece3567labs ECE 3567 Microcontrollers Material: Lab instructions are presented in class Additional material is available at: https://u.osu.edu/ece3567labs   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

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

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

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 2011. 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.

ANSI C Keywords

C Conditional Statements

C Loop Control

C Loop Statements

C – Variable Types

C – Floating Point Variables

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.

C – Arithmetic Operators

C – Relational Operators

C

C – Logical Operators

C – Bit Operators

C – Ternary Operators

The ASCII Character Set

C – Escape Sequences used in Formatting

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.

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!

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.

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

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 00000001b), 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 11111110), 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

The MSP430FR6989 Microcontroller Architecture ECE 3567 Microcontrollers The MSP430FR6989 Microcontroller Architecture

The MSP430FR6989 Microcontroller Architecture

The MSP430FR6989 Microcontroller Architecture

ECE 3567 Microcontrollers Code Composer Studio (Version 7.2.0.00013)

Code Composer Studio Compile Debug Run Stop

ECE 3567 Microcontrollers Code Composer Studio (Version 7.2.0.00013)

The Controller Project