34
Welcome to EELE 101 and the Introduction to C Programming section of the course. Dr. Ross Snider Associate Professor Electrical and Computer Engineering Department Montana State University - Bozeman Revised August 2014

Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Embed Size (px)

Citation preview

Page 1: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Welcome to EELE 101 and the

Introduction to C Programming section of the course.

Dr. Ross Snider Associate Professor

Electrical and Computer Engineering Department Montana State University - Bozeman

Revised August 2014

Page 2: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

• What’s the difference between Computer Engineering and Computer Science?

• Why C? • How this semester will unfold.

EELE 101 : Introduction to C Programming

Overview

Page 3: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

What is the Different between Computer Engineering and Computer Science?

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

Computer Science

Increasing Level

of Abstraction

Computer Science What can theoretically be done?

Computer Engineering

Decreasing Level

of Abstraction

Computer Engineering What can practically be done?

Can we improve the circuits (faster, lower power, etc)?

Page 4: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

What is the Different between Computer Engineering and Computer Science?

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

Computer Science

Programming Languages and Methodology, Data Structures, Algorithms Computer Architecture and Elements, Computational Theories Software Engineering

Computer Engineering

Electronics Digital Logic, Algorithms

Microprocessor Programming Digital Signal Processing, Embedded Systems

VLSI Design and Manufacturing

Page 5: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

ARM Cortex-M0+ (Freescale MKL25Z128VLK4)

Page 6: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

The ECE Department Focuses on Embedded Systems

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

An embedded system is a computer system designed for a specific function within a larger system. It typically provides control, signal and sensor processing capability and often preforms this with real-time computing constraints.

Microcontrollers and Microprocessors are the “Brains”

of Embedded Systems

Page 7: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Microcontrollers are Found Everywhere

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

Microcontrollers are the computers you DON’T see.

The BMW's 7 Series is said to have 70 microcontrollers* on board!

*http://www.designnews.com/document.asp?doc_id=228519

Page 8: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Microcontrollers are Found Everywhere

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

The average MCU price declined from $1.08 in 2010

to $1.06 in 2011, and will drop to $1.05 in 2012

according to IC Insights.

MicroControllers are Cheap

http://www.digikey.com/purchasingpro/us/en/articles/semiconductors/ expect-soft-prices-and-short-leadtimes-for-microcontrollers/1267

There are a lot of them!

The average price for a microcontroller will drop, but the decline will be relatively small as more 32-bit MCUs are designed into equipment.

Growing use of microcontrollers in more equipment will drive revenue growth through 2016.

These two plots imply that there were 14 Billion

Microcontrollers sold in 2010 with a projection of

24 Billion to be sold in 2016

Page 9: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Microcontrollers are Found Everywhere

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

A market study from Grand View Research, Inc. outlines the following: • Global microcontroller market was estimated at 17,393.6 million units in 2013, and is expected to reach 39,108.5 million units by 2020, growing at a CAGR of 12.3% from 2014 to 2020. • 32-bit microcontrollers accounted for over 34% of the market in 2013; the segment is further expected to dominate global market revenue over the next six years. It is also expected to be the fastest growing product segment, at an estimated CAGR of 13.0% in terms of volume from 2014 to 2020. • Automotive accounted for over 30% of the market in 2013, and is expected to remain the largest application area over the next six years. Consumer electronics occupied over 20% of the global market share in 2013. Increasing proliferation of these devices and technological advancement are expected to give impetus to the market over the forecast period. http://www.grandviewresearch.com/press-release/global-microcontroller-market

Page 10: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why learn C as a programming language?

http://www.opendocs.org/images/progLanguages.jpg

Wikipedia lists hundreds of languages http://en.wikipedia.org/wiki/List_of_programming_languages

Page 11: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why learn C as a programming language?

C is the most popular programming language.

The August 2014 ranking for C is 16.4% (Java is 15.0%)

The TIOBE Programming Community index is an indicator of the popularity of programming languages.

Page 12: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why learn C as a programming language?

C is the most popular programming language.

Programming Language Popularity http://langpop.com/

Page 13: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why learn C as a programming language?

C is the most popular programming

language in active open source projects.

This Year’s Language Use (August 2014) as tracked by BlackDuck http://www.blackducksoftware.com/resources/data/this-years-language-use

Page 14: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why learn C as a programming language?

http://www.embedded.com/electronics-blogs/programming-pointers/4372180/Unexpected-trends

Page 15: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

http://www.embedded.com/electronics-blogs/programming-pointers/4372180/Unexpected-trends

C is the most common language used in Embedded Systems

Page 16: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Why does C dominate programming languages used in Embedded Systems ?

http://programmers.stackexchange.com/questions/84514/why-does-c-dominate-in-the-embedded-software-market

1.Performance. 2. C was designed to model a CPU, which means

that C programs work well as an abstraction level for embedded CPUs.

3. Availability of compilers (free). Wide support. 4. Code size is smaller (important for small

microcontrollers). 5. Less overhead. 6. A lot of people already know C (hiring concerns).

Page 17: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

The C programming effort will be divided into three segments. Each segment will be ~5 weeks long. 1. Introduction to the C Programming Language. 2. Using C to target the embedded board that

came with your Freescale Cup kit 3. Using C to control your Freescale race car

How this semester will unfold.

Page 18: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

The material on C programming will be divided into the following three sections (each section will be ~5 weeks long): 1. Introduction to C. 2. Using C to target the embedded board that

came with your Freescale Cup kit 3. Using C to control your Freescale race car

Page 19: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

We will use the Microsoft’s VisualStudio to write our first few C programs. All ECE labs with computers will have Visual Studio on them. You will be able to install Visual Studio on your own laptops, but until you get and install the software, you will need to use the ECE computer labs. The ECE computer lab is located in Cobleigh Hall 625 (6th floor, SouthWest inside corner).

EELE 101 : Introduction to C Programming Introduction to C

Page 20: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

MSU has a site license for Microsoft product’s, so you will be able to download your own version from the Microsoft DreamSpark website: https://www.dreamspark.com/ and install it on your own laptop. (Having your own laptop is highly recommended). Be on the lookout for the following email as it will contain information on how to access your DreamSpark account. All students registered for EELE 101 should get an email with the following subject & from fields: Follow the instructions contained in the email.

EELE 101 : Introduction to C Programming Introduction to C

subject: An account has been created for you from: Montana State University - Electrical & Computer Engineering - DreamSpark Premium <[email protected]>

Page 21: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

When you get done with EELE 101, will you be an expert C programmer?

No Will you be an OK C programmer after this course?

Maybe, probably not. Will you get a feel for what it takes to program an embedded systems?

Yes

Page 22: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

This course only introduces you to the C programming language. You will be expected to take the Computer Science Department’s course on C programming next spring.

CSCI-112 is the CS Dept.’s course on

C Programming

Page 23: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

C Programming Resources The best way to learn to code is to start coding! You can easily find C programming resources on the Internet. Do a google search using “C programming tutorial”. A couple good resources are:

http://www.cprogramming.com

http://c.learncodethehardway.org/book https://inculcate.me/school/courses/4 The author has a set of videos that can be purchases for $29 where he walks you through many code examples.

Click on the C tutorial link under the Tutorials section on the left side of the web page.

Learn C http://www.learn-c.org

Page 24: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

The material on C programming will be divided into the following three sections (each section will be ~5 weeks long): 1. Introduction to C. 2. Using C to target the embedded board that

came with your Freescale Cup kit 3. Using C to control your Freescale race car

Page 25: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Targeting the Kinetis L Series

Freedom Development Platform

This is the microcontroller board that controls the race car!

The microcontroller is the MKL25Z128VLK4 MCU ARM Cortex M0+ 48 MHz, 128 KB flash, 16 KB SRAM, USB OTG (FS), 80LQFP It comes in a 80-Pin LQFP package (QFP = Quad Flat Package LQFP = Low profile QFP)

The board on costs $12.95 and can be bought at: http://www.mouser.com/new/freescalesemiconductor/freescale-freedom-kl25z/

Page 26: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Targeting the FRDM-KL25Z board

Page 27: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Targeting the K20 Embedded board

We will use Freescale’s CodeWarrior IDE to program the KL25Z in C

Page 28: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Targeting the K20 Embedded board

Students can download a free version of CodeWarrior (Special Edition) at: http://www.freescale.com/webapp/sps/site/overview.jsp?code=CW_SPECIALEDITIONS Select the following edition from the list: Special Edition: CodeWarrior for Microcontrollers (latest version is 10.6) Note: This is a ~1.4 GB file download. The ECE office will have a flash drive that you can use to copy this file to your laptop. Bring your laptop with you so you can copy the files while you are in the ECE office (or in a neighboring lab, preferably, if the office is busy).

Page 29: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

The material on C programming will be divided into the following three sections (each section will be ~5 weeks long): 1. Introduction to C. 2. Using C to target the embedded board that

came with your Freescale Cup kit 3. Using C to control your Freescale race car

Page 30: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Controlling the Race Car

Page 31: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Controlling the Race Car

The goal is to be the fastest car on the track (and stay on track). (The track is a black line on a white background)

Page 32: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming Controlling the Race Car

The tasks the K20 must perform are: 1. “See” the black line. 2. Control Steering 3. Control Speed:

a) Slow enough to stay on track. b) Fast enough to win the race.

Team Freescale's show car, er..van.

Cutting the corner. Team "Success" Continental car (2012).

This car was unique in that they utilized two cameras.

Page 33: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

EELE 101 : Introduction to C Programming

1. Watch the Online lecture(s). 2. Take a Quiz on D2L on the lecture material. 3. Work on the C programming exercise(s) assigned. 4. Upload your attempted code to a D2L dropbox BEFORE your

Recitation Section and answer a code survey question. 5. Demonstrate your program during the Recitation Section or

get help on your code if you need it. 6. Upload your final well commented C source Code to the D2L

dropbox.

What you will need to do each week for the C programming part of the course.

Note: It is highly recommended that you have your own laptop and install the student version CodeWarrior. You should do this as soon as possible so that the programs will be ready when you need to use them.

Page 34: Welcome to EELE 101 - Montana State Universityece.montana.edu/other/c-programming/Week_01_video_1_overview_2014.pdf · Welcome to EELE 101 and the Introduction to C Programming

Computers and the Human Experience

Introduction to C Programming EELE 101 : Introduction to Electrical Fundamentals

Out of the last ~5,000 years of recorded human history, computers have only been on the scene for 68 years and

have made a dramatic impact on society!

No Computers

~5000 years of Recorded Human History ~3000 BC

Beginning of Written History

1946 First Electronic Computer (ENIAC)

The ENIAC was made of 17,468 vacuum tubes, weighed 30 tons, took up 1800 ft2 of floor space,

consumed 150 KW of power (enough to power 25 homes), and was slower (0.05 MIPS) than

your cheap pocket calculator. http://en.wikipedia.org/wiki/ENIAC

2014

What will the future bring? How will you shape the future with computers!

“Stick writing in the mud”

Smartphone and 128 GB flash drive in your pocket