EECS 100 Microcontroller Laboratory B Boser University of California Berkeley Department of Electrical Engineering and Computer Sciences EECS 100 Professor Bernhard Boser LABORATORY 9 v3 MICROCONTROLLER Microcontrollers are very much slimmed down computers No disks no virtual memory no operating system Think of them just like other circuit components with the added benefit of being configurable with a program Because of this microcontrollers can be coaxed to do all sorts of things simply that otherwise would require a large number of parts Simple microcontrollers cost less than a dollar and hence can be used in almost any project Indeed they can be found in toys electric tooth brushes appliances cars phones electronic keys you name it Being programmable also means that they must be programmed In EE100 focus on the electrical interface of microcontrollers and their use as electronic components The programs we use are very simple and consist to a large part of pasting snippets of code together In fact much like checking the application notes of electronic components for circuits that do what we need it s always a good idea to search the web for code that performs the job we need or is at least a good starting point Most of the code snippets shown in these lab guides are copies of code from the manufacturer s website Feel free to improve on the example programs At least half a dozen simple microcontrollers are available from several manufacturers all with their own advantages and quirks In this course we use the MSP430 from Texas Instruments whose strength are low power dissipation and a regular instruction set Neither feature is critical for EE100 and we could use another part just as well Page 1 EECS 100 Microcontroller Laboratory B Boser The diagram above shows the architecture of the MSP430 specifically the model MSP430F2012 CPU is the part that actually performs computations e g additions Note that microcontrollers usually lack hardware for multiplication or division These operations can be emulated in software albeit at the price of low execution speed The clock system sets the operating speed 16MHz maximum for the controller we are using compare this to 2GHz or so for present day laptops A 555 timer like clock is built right into the chip alternatively an external oscillator can be used if higher precision is required Flash is a nonvolatile memory for storing programs and configuration data RAM is where temporary variables go Note again the contrast to full blown computers microcontroller memory is typically a few kBytes flash and a few hundred Bytes RAM Most laptops today have at least a GByte RAM a million kBytes You don t need this in an electrical tooth brush JTAG and Spy Bi Wire is a nifty interface for programming and debugging it s got no keyboard or LCD display We will use this interface to talk to the controller though USB from a desktop computer This of course is used only for development once completed the controller works standalone from the program stored in Flash memory The really interesting parts are the peripherals Ports P1 and P2 are digital I Os that can be configured as inputs or outputs They can be used for simple I O with switches or LEDs in later labs we will see much more sophisticated uses of this simple interface The other block we will use is the ADC10 a 10 bit analog to digital converter that serves as a bridge between the usually analog real world and the microcontroller For example we can use it to interface the strain gage circuit designed in an earlier lab to the microcontroller and make a full blown simple balance with display out of the combination The diagram above shows the pinout of the MSP430F2012 It has only 14 pins for power VCC and ground VSS the debug interface TDIO and TCK and ports P1 and P2 Looking carefully you will observe that there are eight pins for P1 but only two for P2 The other ones don t fit with a 14 pin package There also are no separate pins for the ADC Instead digital IO pins can be reprogrammed as ADC inputs as needed Several dozen MSP430 microcontrollers are available with their main difference being the number of pins and the amount of memory This permits you to start with a small model and as the project grows move to models with more features without having to change the programs developed for the smaller parts With only 14 pins we certainly could wire up the microcontroller on a protoboard The custom board shown below makes wiring even simpler It also features LEDs for debugging and a touch interface which we will use in a later laboratory In addition to the microcontroller the board features a header for interfacing with a ribbon cable to the USB interface which is also supplying power to the board Three capacitors and a resistor are used for filtering power and resetting the device after power is applied These devices are specified by datasheet of the device A header strip on the left side of the board exposes P1 and P2 and power for prototyping Page 2 EECS 100 Microcontroller Laboratory B Boser Alternatively P1 also can be connected to onboard LEDs trough jumpers This of course makes sense only for pins that are configured as digital outputs Removing a jumper or setting it on a single pin as shown for P1 3 for not losing it makes that port available for other functions such as digital input or the ADC The rightmost position VCC is for monitoring the power supply and always on when power is supplied to the board and the jumper is inserted Jumper the upper two terminals of J3 as shown to enable power from the USB interface Page 3 EECS 100 Microcontroller Laboratory B Boser LAB REPORT Lab Session Name 1 SID Name 2 SID You will have to read through all of this to do the prelab in part 3 1 Blinking light In this laboratory we will familiarize ourselves with the EE100 uController board and the MSP430 development tool We will start with writing the notorious Hello World which for a uController is a blinking light 1 Connect the EE100 uController PCB to the desktop computer with the ribbon cable and the MSP430 USB Debug Interface MSP FET430UIF Use a standard USB cable to connect the debug interface to a computer with the IAR Embedded Workbench IDE software This software is installed on the computers in the EE100 laboratory Alternatively you can download it from the TI website and install on your own computer if you prefer 2 Start the IAR Embedded Workbench IDE Choose Create new project in current workspace A dialog
View Full Document
Unlocking...