You are on page 1of 21

EE192C - Lecture 1

EE192C: Embedded Systems Engineering!
Course Overview & Basics Review! April 1, 2008!

Max Klein ! STARLab - VLF Group ! Office: Packard 351, x33789 ! Lab: Packard 075, x60333 ! maxklein@stanford.edu !
EE192C - Klein! 1 !

What is an Embedded System?
!" No standard (e.g. IEEE, etc) definition! !" A system in which a processor/microcontroller/computer is embedded to perform a specific task or tasks!
!" Often have sensing, processing, storage, and communication!

!" Although task-specific, general purpose processor are often used!
!" ASICs enhance performance, but cost time and money to develop!

!" Blurry, moving line between ES and PCs!

EE192C - Klein!

2 !

nuclear power plant management. and is a truly interdisciplinary activity! !" Requires both hardware and software! !" Hardware interfaces to the real world! !" Sensors and actuators! !" Software controls this real-world interaction! !" End product is a tangible item that does something for you! !" The ES industry is huge. home appliances.Klein! 3 ! . collision detection.com)! EE192C .Motivation !" Embedded Systems are extremely common in everyday life! !" Cell phones. vehicle navigation. targeting and fire control systems. with huge stakes! !" Aircraft control. MP3 Players. and growing each year! !" About 98% of processors shipped are used in embedded systems (embedded. etc! !" Real Time ES support critical applications. medical applications! !" Building these systems is very rewarding.

Klein! 4 ! . you will design the hardware itself! !" Generalized ! !" Some assignments will be done the hard way! !" The knowledge you will gain will apply to implementing subsystems of future protocols. even when not directly supported in hardware! !" We must have a platform to learn on. relatively simple 8-bit RISC microcontroller! !" Future work with ARM. but rather designing them!! !" Goal is to create systems to fill a gap in what"s available COTS! !" They won"t be pretty to start with. however the principals are generic! !" We"ll use an inexpensive.EE192C: What is it? !" Hands on! !" You will start by programming an existing hardware development kit! !" During the second half of the course. XSCALE. so make friends in Product Design! EE192C . etc is just an increased set of registers and peripherals! !" Gadget Class! !" We"re not going to be using gadgets.

developing an integrated systems utilizing most of the available peripherals in the development kit! !" In the second half of the class. we"ll cover the actual hardware and electronics of the peripherals you are utilizing in software! !" The midterm project will be software-only.Klein! 5 ! . you will understand the software implication of how you implement your hardware! !" We will design hardware beginning with a functionality description. all the way through an actual PCB layout ! !" You are welcome to fabricate the hardware outside of class! EE192C .Course Flow !" We"ll start by programming known-good hardware! !" This programming requires an understanding of the underlying hardware! !" It"s much easier to debug a system when you already know that either the software OR hardware is functional! !" Along the way. you will design hardware! !" At this point.

and address space! !" How a processor can interact with external devices! !" General Purpose I/O! !" Outputs (LEDs)! !" Inputs (Buttons.Klein! 6 ! .Course Outline !" Basics Review! !" Number Systems. memory. binary and hexadecimal math! !" Microcontroller Overview! !" System Blocks! !" Registers. Keypad)! !" Communication Methods! !" !" !" !" RS-232! Character LCDs! I2C / TWI! SPI! !" Solid State Storage! !" Compact Flash / IDE! !" Secure Digital / MMC! EE192C .

Interrupts.Course Outline (cont. and Real Time Systems! !" Definition of hard vs soft real time! !" IRQs and ISRs! !" Preemption! !" Mid-term Project: Software Design! !" System Design! !" Requirements specification! !" Hardware selection! !" ASICs! !" Power Budgets.) !" Timers.Klein! !" Final Project: Hardware Design! 7 ! . analog and digital separation! EE192C . power planes. Batteries. chargers! !" Software implications of hardware choices! !" OrCAD PCB Design Suite! !" Capture CIS for schematics! !" Layout Plus for PCB routing! !" Lots of practical information and hints for PCB layout! !" Avoiding noise.

Klein! 8 ! . as well as making notes of what you"ve tried on a project that didn"t work. This includes commenting your source code and schematics. and other aides that you would normally have in the lab are encouraged (except for the quizzes!).! !" Notes. it will be you continuing someone else"s project. calculators. By the end of this course. both hardware and software.EE192C Overview !" This course is designed to provide you with the theoretical and hands-on skills necessary to design real embedded systems.! !" Documentation of what you do is required.! EE192C . interrupt anytime if something is not clear.! !" Ask questions! Don"t wait until the end of the lecture. you will have developed your own embedded system from scratch. Expect that someone else will improve upon your work in the future. One day. so please try not to leave them in the dark. Don"t let a simple math mistake doom your system.

Klein! 9 ! .! !" There will be regular 5-10min quizzes in class over any material taught in the class to date.EE192C Format !" There is no textbook. The lecture slides will be available from http://eeclass. Keep your code modular and commented.stanford.! !" There will be weekly homework/programming assignments that will directly help you on the projects.! !" There will be no mid-term or final exam! !" There will be two projects: one software and one hardware. ! !" Discussions as a class are encouraged.edu/ee192c/ . a select few of which will be on the course site (most every manufacturer will provide you with one for free from their web site). The quizzes should be easy if you learn the material as you go. Don"t be shy!! EE192C . These are designed to ensure that you understand the material that you will need to apply on the projects and in future systems development. Manufacturer Data Sheets will supplement this material.

lowest score dropped.EE192C Grading !" 20%: In-class quizzes! !" Equally weighted.Klein! 10 ! . No credit if late.! !" 20%: Weekly Homework / Programming Assignments! !" Assigned in class on Thursdays! !" Due at 12:50 on Thursdays (start of class)! !" 15% per day late penalty! !" 30%: Software Project (mid-term)! !" 20% per day late penalty! !" 30%: Hardware Project (final)! !" 20% per day late penalty! EE192C .

Helpful Background !" Computer architecture! !" CPU Registers! !" Memory Addressing! !" Data Paths! !" Basics! !" Number Systems! !" Decimal! !" Hex! !" Binary! !" Electronics! !" Ohm"s Law! !" Basic functionality and use of resistors. transistors.Klein! Linked Lists! Hash Tables! Ping Pong Buffers! Circular Buffers! 11 ! . and diodes! !" Bitwise Operations! !" C / C++! !" !" !" !" Function Calls! Memory Allocation! Header Files! If/for/while/switch statements! !" Data Structures! !" !" !" !" EE192C . capacitors.

Klein! 12 ! . Hexadecimal (Base 16) and Binary (Base 2) very extensively. .F]: EE192C . x10-1 x2-1 x16-1 x10-2 x2-2 x16-2 x10-3 x2-3 x16-3 Binary [0. . so make sure you know it! ! Decimal [0.1]: Hexadecimal [0.9]: x102 x22 x162 x101 x21 x161 x100 x20 x160 .Number Systems !" We"ll be using Decimal (Base 10).

Logic / Boolean Algebra !" We will only be reviewing AND. and Equality operations! !" Others are used.Klein! 13 ! . <>. such as <. ==. as they usually function as expected! !" Most of our review will utilize C-style nomenclature (ie == is equality)! & = bitwise AND! && = logical AND! AND 0 0 1 0 0 1 0 1 | = bitwise OR! || = logical OR! OR 0 0 1 0 1 1 1 1 EE192C . OR. <=. >. You should already know these. >=. ~.

Klein! .Bitwise Operations Example of bitwise AND: 0xB4 & 0x9A =! 0x90! 1 & 1 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 Example of bitwise OR: 0xB4 | 0x9A =! 0xBE! 1 | 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 14 ! EE192C .

Klein! . True or False. This makes equalities behave differently than intuition may dictate:! 001 && 110 = ! 100 && 001 = ! 001 && 001 ! (All are TRUE. Logical Ops & 00 01 10 11 && 00 01 10 11 00 00 00 00 00 00 0 0 0 0 01 00 01 00 01 01 0 1 1 1 10 00 00 10 10 10 0 1 1 1 11 00 01 10 11 11 0 1 1 1 | 00 01 10 11 || 00 01 10 11 00 00 01 10 11 00 0 1 1 1 01 01 01 11 11 01 1 1 1 1 10 10 11 10 11 10 1 1 1 1 11 11 11 11 11 11 1 1 1 1 Bitwise operations will usually return the same number of binary digits as used in the input.Bitwise vs. but is sometimes zeropadded on the left ! Notice that the logical operators return a single value. and 1 = 1 = 1) ! 15 ! EE192C .

Klein! 16 ! .! !" |. or read specific bit(s) within a byte without clobbering the remaining bits! !" Masking is simply a specific use of bitwise operations! !" !" !" !" Two arguments will be the variable and the mask! & is used for read masking and CLEAR write masking! | is used for SET write masking! Since & requires BOTH bit in the column to be true for the result to be true. on the other hand. and also provides a bit of insight on how to create your own flags that don"t occupy an entire byte! EE192C . while allowing other columns to retain their existing value! !" This will be used later on in setting and reading various processor registers. will always produce a 1 if there is a 1 in that position in the mask. only column(s) with a 1 in the mask can possibly result in a 1 in the answer.! !" Using &. clear. This is how you can ignore all but selected columns in a bit string.Bit Masking !" Bit masking allows you to set. This is used to set bits to 1. one can create a mask to set selected bits to 0.

Klein! 17 ! . and 0 in the remaining places! 1 & 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 Variable! Mask! Result! Now that the result is a masked version of the variable only containing the column we want.! EE192C . we would want the mask to have a 1 in the 3rd column. Let#s say we only want to read the value in column 3 of the bitstring. for example. branch if that particular bit in the variable is set (1) or cleared (0).Bit Masking. Read Ex. If we use bitwise AND. we can use logical expressions to.

so that the columns ORed with a 0 in the mask will keep their values.! 1 | 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 1 0 0 0 0 0 0 Variable! Mask! Result! As expected. the 4th column is 1 and the remaining columns# values are unchanged. This means the mask should have a 1 in column 4 and zeros elsewhere. while preserving the remaining columns original values. Set Ex. Now.Bit Masking. Note that we now will be using a bitwise OR.Klein! 18 ! .! EE192C . let#s make the 4th column of the bitstring a 1.

let#s now make column 6 a zero. This is a bit more tricky.Bit Masking. We will use the bitwise AND.Klein! 19 ! . Lastly. this would be:! 0xFF . while keeping every other value as-is. For the above example.0x20 = 0xDF ! EE192C . and have the mask be 1 in every column except the 6th.! 1 & 1 1 0 1 0 1 0 0 1 1 1 0 1 0 1 1 1 0 1 0 0 1 0 Variable! Mask! Result! The mask can also be computed by subtracting the value of the column(s) of interest from all ones. Clear Ex.

make sure you both know the index of whatever it is your are talking about (in this lecture we covered columns of a bit string)! !" Some things are 0-indexed. not 1! EE192C .Bit Masking Gotchas !" Remember the difference between Logical and Bitwise operations!! !" When communicating with someone else.Klein! 20 ! . ie the first position is called 0.

Klein! 21 ! .Questions? EE192C .