Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Max Klein ! STARLab - VLF Group ! Ofce: Packard 351, x33789 ! Lab: Packard 075, x60333 ! maxklein@stanford.edu !
EE192C - Klein! 1 !
EE192C - Klein!
2 !
Motivation
!" Embedded Systems are extremely common in everyday life!
!" Cell phones, MP3 Players, home appliances, vehicle navigation, collision detection, etc!
!" Building these systems is very rewarding, 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!
!" 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, however the principals are generic!
!" We"ll use an inexpensive, relatively simple 8-bit RISC microcontroller! !" Future work with ARM, XSCALE, etc is just an increased set of registers and peripherals!
EE192C - Klein!
4 !
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, we"ll cover the actual hardware and electronics of the peripherals you are utilizing in software! !" The midterm project will be software-only, developing an integrated systems utilizing most of the available peripherals in the development kit!
!" In the second half of the class, you will design hardware!
!" At this point, 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 - Klein!
5 !
Course Outline
!" Basics Review!
!" Number Systems, binary and hexadecimal math!
!" 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, power planes, analog and digital separation!
EE192C - Klein!
7 !
EE192C Overview
!" This course is designed to provide you with the theoretical and hands-on skills necessary to design real embedded systems. By the end of this course, you will have developed your own embedded system from scratch, both hardware and software.! !" Notes, calculators, and other aides that you would normally have in the lab are encouraged (except for the quizzes!). Don"t let a simple math mistake doom your system.! !" Documentation of what you do is required. This includes commenting your source code and schematics, as well as making notes of what you"ve tried on a project that didn"t work. Expect that someone else will improve upon your work in the future, so please try not to leave them in the dark. One day, it will be you continuing someone else"s project.! !" Ask questions! Don"t wait until the end of the lecture, interrupt anytime if something is not clear.!
EE192C - Klein!
8 !
EE192C Format
!" There is no textbook. The lecture slides will be available from http://eeclass.stanford.edu/ee192c/ . Manufacturer Data Sheets will supplement this material, 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).! !" There will be no mid-term or nal exam! !" There will be two projects: one software and one hardware.! !" There will be weekly homework/programming assignments that will directly help you on the projects. Keep your code modular and commented.! !" There will be regular 5-10min quizzes in class over any material taught in the class to date. These are designed to ensure that you understand the material that you will need to apply on the projects and in future systems development. The quizzes should be easy if you learn the material as you go. ! !" Discussions as a class are encouraged. Don"t be shy!!
EE192C - Klein! 9 !
EE192C Grading
!" 20%: In-class quizzes!
!" Equally weighted, lowest score dropped. No credit if late.!
EE192C - Klein!
10 !
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, capacitors, transistors, and diodes!
!" C / C++!
!" !" !" !" Function Calls! Memory Allocation! Header Files! If/for/while/switch statements!
Number Systems
!" We"ll be using Decimal (Base 10), Hexadecimal (Base 16) and Binary (Base 2) very extensively, so make sure you know it!
Decimal [0,9]:
. . .
Binary [0,1]:
Hexadecimal [0,F]:
EE192C - Klein!
12 !
EE192C - Klein!
13 !
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
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!
Bitwise operations will usually return the same number of binary digits as used in the input, but is sometimes zeropadded on the left ! Notice that the logical operators return a single value, True or False. This makes equalities behave differently than intuition may dictate:! 001 && 110 = ! 100 && 001 = ! 001 && 001 ! (All are TRUE, and 1 = 1 = 1) !
15 !
EE192C - Klein!
Bit Masking
!" Bit masking allows you to set, clear, or read specic bit(s) within a byte without clobbering the remaining bits! !" Masking is simply a specic 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, only column(s) with a 1 in the mask can possibly result in a 1 in the answer. This is how you can ignore all but selected columns in a bit string.! !" |, on the other hand, will always produce a 1 if there is a 1 in that position in the mask. This is used to set bits to 1.! !" Using &, one can create a mask to set selected bits to 0, while allowing other columns to retain their existing value!
!" This will be used later on in setting and reading various processor registers, and also provides a bit of insight on how to create your own ags that don"t occupy an entire byte!
EE192C - Klein! 16 !
1 & 0 0
0 0 0
1 0 0
1 0 0
0 0 0
1 1 1
0 0 0
0 0 0
Now that the result is a masked version of the variable only containing the column we want, we can use logical expressions to, for example, branch if that particular bit in the variable is set (1) or cleared (0).!
EE192C - Klein! 17 !
1 | 0 1
0 0 0
1 0 1
1 0 1
0 1 1
1 0 1
0 0 0
0 0 0
As expected, the 4th column is 1 and the remaining columns# values are unchanged.!
EE192C - Klein! 18 !
1 & 1 1
0 1 0
1 0 0
1 1 1
0 1 0
1 1 1
0 1 0
0 1 0
The mask can also be computed by subtracting the value of the column(s) of interest from all ones. For the above example, this would be:! 0xFF - 0x20 = 0xDF !
EE192C - Klein! 19 !
EE192C - Klein!
20 !
Questions?
EE192C - Klein!
21 !