Lab 1 Course Guideline and Review Overview Welcome to ECE 3567 Introduction to Microcontroller Lab. In this lab we are going to experimentally explore various useful peripherals of a modern microcontroller using assembly language in a debugging environment. We expect that after this semester you will have a better understanding of what microcontrollers can do. You will polish up on how to program MCUs (Microcontrollers) in assembly language, understand basic design concerns, programming practices and unleash the power of a debugger to help you with programming in various way. We are going to use the TI (Texas Instruments) MSP430G2553 microcontroller located on the TI experimenter s board known as the LaunchPad. For writing and debugging assembly code we are going to use a software IDE (Integrated Design Environment) named Code Composer Studio version 5 (CCSv5). This software is free for download from Texas Instruments Website (http://processors.wiki.ti.com/index.php/download_ccs). We recommend that you to install CCSv5.1.x on your laptops instead of higher versions of CCS to be best compatible with our lab environment. You are going to be working in groups of three. There will be a group lab report for each lab. Quizzes and projects (if any) will be based on individual and not group effort. Please refer to the course syllabus regarding detailed course composition, HW due dates and grading weights/policies etc. We highly recommend the book, MSP430 Microcontroller Basics by JohnH.Davis, as your reading material if you want to learn more.
Microcontroller and Experimenter s Board As you no doubt already known, microcontrollers play an important role literally in every aspect of our daily life. The picture below gives us just a glimpse of this fact. (source: http://www.ti.com/corp/docs/press/backgrounder/dsp.shtml) There is a vast selection of microcontrollers in the market from various manufacturers like Freescale, TexasInstruments, Atmel etc. The question you need to ask is: What microcontroller should you choose for your products/projects? What specifications should you look for to fulfill your design requirements? In order to help you in prototyping a microcontroller before using it in your final design, manufacturers of microcontrollers often carry products called experimenter s boards or explorer kits (or some other similar name). These kits carry various input and output headers, LEDs, buttons, sensing devices,
communication interfaces etc. already prewired on the kit board to the microcontroller you are interested in. In this course we are going to use the Texas Instruments MSP430G2553microcontroller and the TI Launchpad experimenter s board are shown below. this lab. Note that the Launchpad will be provided to you and you do not need to buy any kit for Learning a Microcontroller You can start using a microcontroller without really having an in depth knowledge about it by using prewritten canned software routines written for you by others or you can develop an in depth knowledge of the workings of a microcontroller by programming it yourself from the grounds up. We are aiming at the latter option in this course. To start, first you need to know the basic features of a microcontroller. You can grab the basic information from the products website with minimal reading required. Here s a summary of MSP430G2553 features collected from TI website. (http://www.ti.com/product/msp430g2553) Microncroller: Family: MSP430G2553 MSP430
Memory: 16 kb Flash 512B SRAM Features: 16 bit RISC CPU 2 Ports, 8 I/O each Watchdog Clock: Internal clock frequency up to 16MHz 32 khz Crystal Internal Low Frequency (LF) Oscillator Two 16 bit Timer On chip comparator 10 bit ADC Low power consumption Please note that the table above is just a brief summary of the features. Based on these specifications, here are our reasons for choosing this microcontroller for the ECE 3567 lab: Typical of a modern day microcontroller, the MSP430G2553 is a versatile RISC based microcontroller featuring multiple clocks, flexible timer modules and a good selection of low power modes, all of which make this microcontroller an excellent tool for beginning in depth education on modern microcontrollers. The maximum RAM of 16kB in theg2xx3 family is sufficient to handle all the programming needs of this lab. The available experimenters board (TI Launchpad) costs less than 10 dollars which all students can afford, if they choose to buy one themselves. Texas Instrument is a multinational cooperation and is also one of the leading and growing companies in embedded systems.
To learn more about microcontrollers in depth, you should study the various data sheets provided by the manufacturer. For TI microcontrollers there are typically one or two sets of data sheets to look through, Family Guide and Device Specific data sheets. Both should be available at the product s website. Studying data sheets is a long but rewarding task. You are not required to read the data sheets from cover to cover but we recommend that you keeping a copy of these with you as a reference. In addition, online forums and videos can also help you to get more information and help, but you should not rely entirely on these resources. Finally, it is imperative to start experimenting by yourself to gain applied experience. You will not really learn until you experiment by yourself and that is the whole aim of this lab! Microcontroller Review **************************************************************************** What Do You Need for This Course As a prerequisite for this course we expect you to know the basics of this microcontroller, Code Composer Studio version 5 and assembly language for the MSP430 series of microcontrollers. If you need to review basics like the assembly code itself, addressing mode, program structure etc. then please go through the MCU_Review I and II screencast videos carefully so that you can keep up with the labs. **************************************************************************** In this section by having you complete the following practice exercises, we will help you: Review using code composer studio with the Launchpad Learn tricks in using the debugger (CCSv5) Debug your workbench
Starting an Assembly Project in Code Composer Studio 1) Create a workspace (Folder where all your projects go into) for your project. Important: Create this workspace on the Z drive. 2) Open Code Composer Studio, You will see a workspace launcher window where you can browse to the directory of your workspace. 3) To create an assembly project, go to Project > New CCS Project 4) A New CCS Project window will pop up. Make sure you set up your program as shown in the following two screenshots.
Especially note legacy COFF in the above screenshot. By accomplishing the steps above, you have successfully created a CCS project in your workspace. You should see a main.asm file sitting in your project (Note that if you see a main.c file then you have chosen the wrong project type, i.e. a C project instead of an assembly project). Also make sure that under the targetconfigs folder, you have MSP430G2553.ccxml sitting in it and its status is [Active].
If you do not see a target configuration file (.ccxml), go to view > target configuration. Then right click in the new work area popped out and select New Target Configuration. Set up your new target configuration as the following: Do not forget to click on the save button under Save Configuration
Complete the following exercises, include your code and screenshots in your lab report. Practice Exercises Exercie 1 Blinky LED Test A blinky LED test is like a hello world program. It is meant for checking basic program and compiler setup, making sure your programs runs. Write an assembly language program that follows the following pseudo code: Loop: Toggle Red LED Delay loop with about 65545 iterations Go to Loop Exercise 2 Push Button, Decision Making and Debug Mode Write an assembly language program that follows the following pseudo code: Loop: If Button S2 is pressed then the Red LED is on and the Green LED is off If Button S2 is not presses then the Red LED is off and the green LED is on Go to Loop Note: Do not forget to set the pull up resistor for the push button. Before you start writing, think about: What pins in port1 or port 2 do you need What configurations do these pins need to be in
Step 1) Does your Code Work? a. Run the program at full speed. Step 2) Observe Values in register window a. Pause the program while push button is not pressed. Observe the bit in the input buffer in the register window that is connected to the push button. Is the observed bit value (0 or 1) what are expecting? Explain. Step 3) Stepping and Breakpoint b. After which line of code should the LED change color? Set break point to observe change of LED color. c. Run the program and let it hit the break points in the debugger to observe LED changes. Perform this step while pressing and not pressing the push button, check your decision making routine. d. Step through your program, are the LEDs lit/dim as expected? e. Is your code working or partially working? Step 4) Debug your code based on the information gathered in step 1 3 Exercise 3 Array Manipulations Write an assembly language program that follows the following pseudo code: Create an array named Array1 with space for five words initialized to zero. Create an array named Array2 with space for five words initialized to zero. Use a loop to fill Array1 with the following values: Array1[0] = 0 Array1[1] = 1
Array1[2] = 2 Array1[3] = 3 Array1[4] = 4 Array2[0] = Array1[0] + 2 Array2[1] = Array1[1] + 2 Array2[2] = Array1[2] + 2 Array2[3] = Array1[3] + 2 Array2[4] = Array1[4] + 2 Step 1) Does your Code Work? a. Run the program at full speed. Step 2) Observe Values in the Memory Browser c. Find Array1 and Array2 in the memory browser d. Step through the program, does the memory locations change as expected? Step 3) Debug your Code Please use this chance to verify that your workspace directory/project settings are bug free; ask questions if you are not comfortable with programming microcontrollers and its peripherals! This will save you valuable time in the coming labs.