Lab 1 An Introduction to Assembly

Size: px
Start display at page:

Download "Lab 1 An Introduction to Assembly"

Transcription

1 Lab 1 An Introduction to Assembly This lab is designed to introduce you to the Arduino Microcontroller Board, Atmel (part of MicroChip) Integrated Development Environment (IDE) and AVR Assembly Language programming. Plus, you will learn about the power of library files. Library files are simply files that you instruct AVR Studio to include in your program. In this lab you are going to include two library files. One named m328pdef and the other spi_shield. You can find this and future lab updates at Please do the step-by-step simulation tutorial at the end of this lab. At the end of this tutorial you should be able to set switches to a given value by toggling Ports D and C Pins. For example, after the tutorial you should be able to show how you would simulate an input of 0xAA. Table of Contents What is New?... 3 AVR Assembly Instructions... 3 AVR Studio Assembly... 3 Introduction to AVR Studio... 4 Create a New Project... 5 Assembly Directives... 6 Assembly Instructions... 7 The Anatomy of an Assembly Instruction... 8 Introduction to the Arduino Proto-shield... 9 The ATmega328P Serial Peripheral Interface The SPI_Shield.inc Include File Quick Review and New Instructions for the Assembler Why are the two include files placed at different locations in the program? Initialization Section How to Initialize the Stack How to Use the InitShield Subroutine Looping Section How to Use the ReadSwitches Subroutine How to Use the WriteDisplay Subroutine

2 Making SPI Software Wires On Your Own Debug Workshop 1 Simulate Your Program Lab Signoff How to Create and Print-out a List (.lst) File Design Challenge (2 points) Lab 1 Deliverable(s) Appendix A: A Quick Look at SPI_Shield How the InitShield Subroutine Initializes the GPIO Ports C and D How ReadSwitches Subroutine Maps the 8 Switches to General Purpose Register Appendix B How the Parts of the Arduino Proto-Shield Work The 74HC595 Shift Register Tri-State Output Buffers Storage Registers (D-Flip Flops) Shift Registers (D-Flip Flops) Seven Segment Display Appendix C Reference

3 What is New? The following instructions and assembly directives are used in Labs 1. If you have any questions on any instructions or assembly directives a nice source of information, in addition to your textbook, is the Atmel AVR Assembler User Guide AVR Assembly Instructions Data Transfer in r6, PINC // Input port C pins (0x09) into register R6 out PORTB, r7 // Output to Port B from register R7 mov r8, r7 // Move data from register r7 into register r8 Arithmetic and Logic clr r16 ser r17 Control Transfer // Clear Register R16 // Set Register R17 call WriteDisplay // Subroutine Call rjmp loop // Jump to the label named loop AVR Studio Assembly Directives.INCLUDE <m328pdef.inc> // < > means the file is in the AVR Studio folder.include spi_shield.inc // means the file is in the project folder.cseg // Code Segment.ORG 0x0000 // Code Origin Labels loop: Comments ; // /* */ 3

4 Introduction to AVR Studio In lab you will be spending most of your time working within an Integrated Development Environment (IDE). For our labs we will be working in the AVR Studio IDE. As shown in the figure below and discussed in the next few sections the IDE lets us write our program in a human readable form, known as assembly, and then translate it into a machine readable form understood by the ATmega328P. Figure 1 AVR Studio IDE Development Steps 4

5 Create a New Project The best way to learn about the AVR Studio IDE is to start playing with it. So let s get things started by launching AVR Studio and Opening a New Project. Select Atmel AVR Assembler and check both check boxes (Create initial file and Create folder). Name your project (Lab1) and browse to location where you want it saved. Click Next >>. In the next window, select AVR Simulator 2. For the Device, select ATmega328P. Click the Finish button. Congratulations, you are ready to start programming within the AVR Studio IDE! 5

6 Assembly Directives All assembly programs contain assembly directives and assembly instructions. Assembly directives are instructions to be read by the assembler. In our lab, the assembler is included with AVR Studio IDE. As you have seen, AVR Studio is a program that runs on your computer and it is responsible for translating your human readable assembly program into the machine language of the microcontroller. We begin our program with an Assembly Directive. First, locate the program window within the IDE. This is the blank window in the center of your AVR Studio application. The title bar should include the location of your program and end with the name of your program and the.asm extension. Enter the following lines into the program window. You can probably guess that here we are telling the assembler that we would simply like to include some comments for the individual reading our code. To include comments, you can use the C language notation // comment line and /* block comment */ or unique to assembly a semicolon ; character. Now let s add some code which intended strictly for the assembler, not the reader or the microcontroller. The difference is important..include <m328pdef.inc>.cseg.org 0x0000 The "dots" tell the assembler that these lines are talking to the assembler and not to be turned into machine instructions. Without overly complicating our first program, I will just note that the INCLUDE assembly directive tells the assembler to copy into our program all the text contained in a file named m328pdef.inc. For now, we do not need to know what is in this file, other than to note it will help us in writing a more human readable program. The CSEG statement tells the AVR Studio Assembler to place the following material in the Code SEGment of memory. For the ATmega328P, this means Flash Program Memory. The ORG statement tells the assembler to start placing code at this address in Flash Program memory. 6

7 Programming Convention Because it is so important to remember when a line is intended for the Assembler (Assembly Directive) and when a line is to be converted to a machine instruction intended for the ATMega328P microcontroller (Assembly Instruction), I always capitalize Assembly Directives and place in lower case letters Assembly Instructions. AVR Studio is not case sensitive, so this convention is not required for your assembly program to assemble correctly - it is however required by the instructor. Now let s add our first label. Enter the following line after the.org 0x0000 assembly directive: RST_VECT: The label RST_VECT stands for ReSeT VECTor and is only there as a point of programming style (i.e., it helps the reader know that the code to be executed on reset follows). What the assembler does is quite a different story. Whenever the assembly sees a label, it places the label name and its corresponding address, in this case we know it is 0x0000, into a look-up table. Label Name RST_VECT Program Address 0x0000 Now if you ever want to reference this location in your program, you can use the name and let the assembler worry about the address. Congratulations, you have for now completed your initial conversation with the assembler. You have asked it to include some comments, include more assembly directives located in another file, setup to write some code at address at 0x0000 in program memory, and finally to associate this address with the name RST_VECT. What you haven t done is write anything that the AVR microcontroller will ever read. Once again it is important to know when you are talking to the assembler and when your code will be used to generate machine instructions to be run by the microcontroller. So let s start generating assembly instructions intended for the microcontroller. Assembly Instructions Just as you are reading the step-by-step instructions on this page so you can write your first program, the microcontroller in Figure 1.2 reads the step-by-step instructions contained in the program to learn what is intended by the programmer. This is the Machine Language of the computer. This language is comprised of only ones and zeros. For example, this binary sequence tells the AVR computer (I will also refer to it as the microcontroller) to set all the bits in register 16 to zero. All these 0 s and 1 s are not very easy for us humans to understand. So instead we humans have created a human like language 7

8 comprised of abbreviations (known as mnemonics). This is known as Assembly Language. By definition then, there is a one-to-one correspondence between a machine instruction and an assembly instruction. For our machine code example, the equivalent assembly instruction is clr r16. Registers Our microcontroller contains 32 general purpose registers labeled R0 to R31. For now you can think of registers like variables which can hold up to 8-bits of information ( = 010 to = 25510). To learn more about number system read Chapter 1 Introduction in your text book or Appendix A - Number Systems in my Lecture 1 notes. It is finally time to write our first assembly instruction. Add the following assembly instructions to your program. The assembly instruction rjmp Reset instructs the microcontroller to jump to the yet to be defined label named Reset. You will also see I have included a comment. The meaning of this comment will become more clear over the remainder of the semester. The Anatomy of an Assembly Instruction Each assembly instruction is defined by an operator and one or two operand fields. For our clr r16 example, The clear instruction s operator is clr and it has one operand r16. Our first program line also contains a single operand instruction, in this case, the operator is rjmp and the operand field is reset. 8

9 Introduction to the Arduino Proto-shield A schematic of our Arduino Proto-shield is shown in Figure 3. It includes 8 switches, 1 push button, 10 discrete LEDs, 1 Seven Segment display, and 2 D flip-flops. If you were to add up all the inputs and outputs required to support this proto-shield you would come up with 29. The Arduino Uno board, designed with the ATmega328P microcontroller, only has 23 general purpose digital I/O pins. So how do we solve the problem? Lucky for us the ATmega328P includes a Serial Peripheral Interface (SPI) subsystem which allows us to send 8-bits of data as a serial string of 1s and 0s. By adding two 74HC595 8-bit Serial-to-Parallel shift registers to our Proto-shield as shown in Figure 3, and using the SPI subsystem, we are able to generate 16 new outputs. We will use these outputs to drive 8 discrete LEDs and our 7-segment display. Figure 3 Arduino Proto-Shield 9

10 The ATmega328P Serial Peripheral Interface Reading: Textbook Chapter Serial Peripheral Interface ATmega328 Datasheet Section 18.2 SPI - Serial Peripheral Interface A conceptual representation of how the ATmega SPI subsystem works with our Arduino Protoshield is shown in Figure 3.1 "SPI Master-slave Interconnection." You can find the original of this picture in Section 18 "SPI - Serial Peripheral Interface" in the ATMEL doc8161.pdf document. On the left is the SPI subsystem, it includes the 8-bit Shift Register and the SPI Clock Generator. To send 8 bits of data to the Arduino proto-shield you simply need to write to this register. The SPI subsystem takes care of the reset including generating the serial data stream and clock signal. On the right is an 8-bit shift register used to convert the serial data stream back to 8 discrete bits of data. For our proto-shield this 8-bit shift register is physically realized as a single 74HC595 Serial-to-Parallel shift register. Two generate the 16 output bits used on the proto-shield we daisy chain two 74HC595s and write to the SPI's 8-bit shift register twice. Figure 3.1 SPI Master-slave Interconnection The SPI_Shield.inc Include File To simplify your life - it is after all the first lab - I have already written all the assembly code you need to work with the Proto-shield. This code is contained in a separate file named spi_shield.inc. We will add this file to our program in the same way we included the m328pdef.inc "include" document an earlier part of this lab. Let s begin. Download and add to your Lab1 project folder my spi_shield.inc file. Unlike, the m328pdef.inc file which contains equate statements, the spi_shield.inc file includes subroutines which need to be run by the microcontroller. 10

11 Add the following lines of code to your Lab1 project file. Original code that you should have already added is shown in gray. Quick Review and New Instructions for the Assembler 1. Can you identify the comments? 2. Can you tell which lines contain Assembly Directives and which contain Assembly Instructions? Remember assembly directives typically, but not always start with a period and use upper case letters; while assembly instructions use lower case letters. Do you remember the first INCLUDE assembly directive from earlier in the lab? The m328pdef.inc library is written by Atmel and allows you to use names in place of numbers. For example PINC which was introduced in lab 1 is equated to the number 0x06 in the library. Here is the actual equate statement from the library..equ PINC = 0x06 So when you press the reset button, the AVR processor will first run the rjmp reset instruction. The rjmp instruction tells the processor to jump to the code starting at the reset label. This means the program will jump over (bypass) a table known as the IVT (to be covered later in the semester) and all the code included in spi_shield.inc. Which is a good thing; because we do not want to run any of the included programs until we are ready. 11

12 I wrote the spi_shield library. This library includes subroutines InitShield, ReadSwitches, WriteDisplay which allow you to work with the Arduino Proto-shield without knowing the details of how it works. Why are the two include files placed at different locations in the program? The m328pdef.inc library is written by Atmel and allows us to use mnemonics (abbreviations like PINC) in place of numbers (like hexadecimal 6). To allow us to use these mnemonic names as quickly as possible we insert this library at the beginning of the program. The spi_shield library is written by the instructor and contains instructions. This code must not be executed at reset so the library is inserted after the first jump instruction (rjmp reset) and above the label reset. If you have played around with the Arduino IDE, you know that all Arduino programs have an initialization section named setup() and a looping section named loop(). Our assembly program written within the AVR Studio IDE will be configured in a similar fashion. In our case, the initialization section is labeled reset: and the looping section is again named loop:. In the next section you will write the initialization section to be used throughout the semester. Initialization Section How to Initialize the Stack To accomplish almost anything useful in assembly you write a subroutine. To allow us to work with the Proto-shield I have written a number of ready-made subroutines for you to use. When you call a subroutine you need to save your current location on a stack. All computers have built-in hardware stack support. However, before we can save our return address on the stack we need to initialize our stack pointer (SP) register. You will learn more about stacks as the semester progresses. Add the following lines of code to your program right after the reset label. ldi r16,high(ramend) // IO[0x3e] = 0x08 out SPH,r16 ldi r16,low(ramend) // IO[0x3d] = 0xff out SPL,r16 How to Use the InitShield Subroutine We are now ready to call our first subroutine. Add the following line to your program. call InitShield 12

13 The InitShield subroutine takes care of all the initialization required to use the Arduino Proto-shield. You only need to call it once at the beginning of your program, just after stack initialization. That is it, you are now ready to use the ATmega328 GPIO Ports and SPI subsystem to work the Arduino Proto-shield - allowing you to read the 8 switches and whenever you want to update the 7 segment display and/or 8 discrete LEDs. To make your life even simpler the spi_shield file also includes the subroutines ReadSwitches and WriteDisplay. Looping Section To programmatically connect our switches to the 7 Segment display we will (1) read the 8 switches into register r6, (2) move register r6 into r7, and (3) then write r7 to the 7 Segment display. We will maintain the connection by looping the program around these three instructions using the Relative Jump (rjmp) instruction. To accomplish steps 1 and 3 you will use two subroutines that I have already written for you named ReadSwitches and WriteDisplay. In the next two sections we will take a closer look at both. You can find out more about these and other instructions in AVR Studio by clicking Help in the menu bar and selecting Assembler Help. Let s take a little closer look at our program and how it works. How to Use the ReadSwitches Subroutine In Figure 3, on the left hand side, you see bits in Register 6 (in purple) assigned to each of the 8 switches. Register 6 is not hardwired to the switches. Instead, we will use the ReadSwitches subroutine to read the GPIO ports and perform all the logical operations needed to map these switches to Register 6. Remember, changing the switches does not automatically change the value in register r6 - you must call ReadSwitches. How to Use the WriteDisplay Subroutine In Figure 3, on the right hand side, you see bits in Register 7 and Register 8 (in purple) assigned to each of the lines controlling the input pins of the 7 segment display and 8 discrete LEDs. To change the 7 segment display or any one of the discrete LEDs, you make the change to bit(s) within the associated register and call the WriteDisplay subroutine. The WriteDisplay subroutine will take care of all of the housekeeping required to map these bits within the registers to their corresponding pins. Please, do not get confused. These registers are not hardwired to the 7 segment display and discrete LEDs. Instead they are used as arguments to the WriteDisplay subroutine which sends them to the SPI Serial Register, which in turn sends 13

14 them as a serial stream of data to the 74HC595 ICs on the Arduino Proto-shield (see Figure 3.1). If you are asking yourself What is a 7 segment display? and What is a 74HC595? among probably many other questions, you can find many of your questions answered in Appendix B How the Parts of the Arduino Proto-Shield Work. Remember, changing bits within these registers does not automatically change the pins on the 7 segment display or discrete LEDs - you must call WriteDisplay. In the next section we will see how the ReadSwitches and WriteDisplay subroutines can be used to create software wires between the 8 switches and 7 Segment display. Making SPI Software Wires Because the switches are not physically connected to the 7 segment display, we must create software wires to transfer the data. In this section, we want to connect all 8 switches to their corresponding segments of the 7 Segment display (the numeric display on the top right in Figure 4) using our two new subroutines and a new assembly instruction. Once you have completed this section, the CSULB shield should work as discussed in the questions from Prelab 1. Figure 4 Photo of Arduino Proto-Shield. 14

15 Let s review what you have accomplished to date. In "The SPI_Shield.inc Include File" section you initialized the stack pointer and included SPI subroutines InitShield, ReadSwitches, and WriteDisplay. You ended by calling InitShield to setup the SPI Subsystem of the ATmega328P microcontroller. In the "How to Use the ReadSwitches Subroutine" section you learned how to connect the 8 switches on the Proto-board to Register 6 (in purple) as illustrated on the left hand side of Figure 4. In the How to Use the WriteDisplay Subroutine section you learned how Register 7 and Register 8 (in purple) can control the input pins of the 7 segment display and 8 discrete LEDs. To make our software wires we simply need to move the contents of Register 6 into Register 7. To do that, we will use the assembly mov instruction. Add the following lines to your program. The rjmp instruction loops back so that future changes made to the switches are sent to the 7 segment display. On Your Own Apply what you have learned by connecting the 8 switches to the eight discrete LEDs. Like the 7 segment display which is mapped to register r7, the eight discrete LEDs are mapped to register r8. Your code should now update both the 8 discrete LEDs and 7 segment display. You only need to call the WriteDisplay subroutine once. 15

16 Debug Workshop 1 Simulate Your Program IMPORTANT The following section summarizes what you learned in Debug Workshop 1 covered in Lab 1 Part A and introduces the step over button to skip over subroutine calls. You must complete this section before starting lab 2. You may/will be tested (ex. Quiz 1) on the information contained in both Debug Workshops (1 and 2) plus you will need to demonstrate proficiency with the simulator (i.e., debugger) as part of the sign-off for lab 1. PLEASE REFER TO THE SIMULATION TUTORIAL FOR ADDITIONAL INFORMATION AND TO UNDERSTAND WHAT YOU ARE DOING. Assemble your program by pressing the Assemble F7 icon. If there are no syntax errors you should see the following line in the Build window pane (usually located at the bottom of the screen). Assembly complete, 0 errors. 0 warnings Important - Reading and Remembering can SAVE HOURS OF TIME! One very common misconception is that when the assembler says there are 0 errors and 0 warnings that your program will work. That is almost always not the case! This message only tells you that the assembler understood everything you entered. Technically speaking, it is saying that your syntax is correct. Unfortunately, ninety-nine times out of a hundred your program still contains "programming" or logical errors. You have to find these errors all by yourself. Luckily, AVR Studio includes a Simulator to help you. Students try to make their broken programs work by making random changes and downloading them to their Arduino boards to see if they "now" work. This process is repeated for hours upon hours until more errors are introduced than corrected. I typically receive an after 4 to 8 hours of frustration, asking why the program doesn't work. The first thing I ask is if they have simulated the program. The typical answer is NO. One of the reasons I am including this lab at this early stage in the course, is so you cannot download to your Arduino board and so make this common mistake. ALWAYS SIMULATE YOUR PROGRAM. Once your program has assembled successfully enter AVR Studio s debug mode by pressing the Assemble and Run icon. If closed, expand the Registers folder in the Processor pane and PORTC and PORTD in the I/O View pane within AVR Studio. Select PORTD. In the window below the I/O View, you will notice that PORTD has three rows of eight bits, represented by square boxes. 16

17 Figure 4 General Purpose I/O Port D Registers Each box corresponds to a flip-flop or pin as defined in Table 1 "Port Pin Configurations." Table 1 Inputs Port Pin Configurations Outputs DDRXn PORTXn I/O Pull-up Comments 0 0 Input No Read "Synchronized" PINXn 0 1 Input Yes 1 X Output N/A Write bit to PORTXn Looking at Figure 4, lets start with the first row and the Port D Data Direction Register (DDRD). Each box in this row corresponds to flip-flop. As defined in Table 1, if this box is filled in (Flip- Flop DDRXn = 1) then this port pin will be an output. Conversely, if the box is not selected then the port pin will be an input. The second row of Figure 4 may be visualized as a physical Port D pin (PIND). If you want to simulate a change on an input pin, say from a switch being toggled, this is the box you would set (input = 1) or clear (input = 0). 17

18 The third row contains the Port D register (PORTD). Each box in this row corresponds to flipflop PORTxn. As described in Table 1, these flip-flops are interpreted differently based on if the port pin is defined as an input (DDRXn = 0) or an output (DDRXn = 1). If DDRXn = 0 (input), then the corresponding PORTXn flip-flop adds (PORTXn = 1) or removes (PORTXn = 0) a Pullup resistor (see fourth column in Table 1). If DDRXn = 1 (output), then the corresponding PORTXn flip-flop defines the output state of the pin. For example, if PORTXn = 1, the pin is driven high. If you want to see how your program modifies a pin defined as an output, PORTXn is the box you would look at. As an example, lets assume all Port D pins are to be inputs with pull-up resistors assigned to the two most significant inputs. In this case all the boxes in the DDRD (second row) would be empty (logic 0) and the two most significant boxes of the last row would be filled in (logic 1). This is the case depicted in Figure 4. The above example corresponds to switches 7 and 6. To simulate turning a switch ON simply check the box corresponding to the desired input pin (PIND). By clicking on the Step Over (F10) your program. button, single step the program to the last line of Now, open the PORTC window by selecting PORTC in the I/O View window. Figure 5 General Purpose I/O Port C Registers 18

19 Let s simulate switch SW0 in the up/on position (logic 1) by checking the first box in the PINC Register. With respect to Table 1 "Port Pin Configurations" and the above image (Figure 5), note that PORT C bit 0 has been configured as an input with a pull-up resistor and the input is currently at logic 1. If it is not already open, expand the Register entry in the Processor window pane (normally located in the upper-left window pane). Notice that register R06 is cleared (0x00) Figure 6 Processor Window Single step (using Step Over) through your program so the input instruction is executed: call ReadSwitches // read switches into r6 In the Processor window you should now see r06 now set to 1 (0x01). Single step your program so the output instruction is executed: call WriteDisplay // write r7 to the 7 segment display If you have followed the lab instructions exactly and correctly written your one line of code, you should now see the following in the processor window: 19

20 Lab Signoff At signoff, you will be given an arbitrary hexadecimal number. You should be able to convert this number to binary and simulate the corresponding switch configuration using the PINC and PIND registers in AVR Studio. You should also be able to use the processor window to demonstrate that your program does, in fact, programmatically wire the switches to the 7- segment display (r7) and discrete LEDs (r8). For example: given 0xA2, input 0b into PINC and PIND registers. Figure 7 Lab Demonstration Example How to Create and Print-out a List (.lst) File At the end of each lab, you will turn in a List file version of your program. A list file contains both your assembly program and the machine program generated by the assembler. First let s verify that AVR Studio is set to generate a List file. In the menu bar select Project and then Assembler Options. Figure 8 Verify that the Create List File check-box is selected. Click OK. 20

21 Now whenever you assemble your program, a file with a.lst extension will be created in your project folder. Assemble your program and then open the generated list file. You will see that along with your program the list file includes a lot of other stuff. Most of this is the text from the included m328pdef.inc document. This is the document that includes all the equate Assemble Directives which allow us to use mnemonics for all our registers in place of their actual addresses. If you have not done so already browse this material to see how AVR Studio does it. You should not turn in this material with your lab so delete it at this time. Delete material from this line... ;***** Created: :36 ******* Source: ATmega328P.xml ********** ;************************************************************************* up to and including this line. ; ***** END OF FILE ****************************************************** Your list file must include the AVR Studio Assembler version and time stamp! AVRASM ver Tue Aug 23 16:57: The "Resource Use Information" should also be deleted before you print out your list file. Delete material from this line... RESOURCE USE INFORMATION up to, but not including this line. Assembly complete, 0 errors, 0 warnings You can clean up and format the final version of your file in AVR Studio or your favorite text editor. Regardless of the text editor your final document should be formatted as follows. Font: Courier or Courier New Size: 9 or 10 point Paragraph Spacing: 0 pt before and after 21

22 Line Spacing: Single Page Layout: Landscape Next, clean up unwanted spaces so your code is aligned and easy to read. DO NOT FORGET THIS STEP. Your touched up list file should now look something like this template. AVRASM ver Tue Jan 10 11:24: /* Lab 1 - An Introduction to Assembly * Version x.0 <- update the version each time to print your program * Written By : Your name here * ID # : Your CSULB student ID number * Date : Date the lab report was turned in, NOT THE DATE DUE * Lab Section : Your day and time */.INCLUDE <m328pdef.inc> ; Initialize Switch with a Pull-up resistor and Discrete Test LED 0 and clr r16 // Clear Register R ef1f ser r17 // Set Register R b907 out DDRC, r16 // Output R16 to I/O Data Direction Reg. Port C b918 out PORTC, r17 // Output R17 to I/O Port C Register, Port C b904 out DDRB, r16 // Output R16 to I/O Data Direction Reg. Port B ; Software Wire loop: b076 in r7, PINC // Input port C pins (0x09) into R b875 out PORTB, r7 // Output to Port B from register R cffd rjmp loop Assembly complete, 0 errors, 0 warnings NOTE: THIS IS JUST AN EXAMPLE. YOUR LIST FILE SHOULD CONTAIN THE CODE FOR LAB 1. Finally, if you have not done so already, set your printer page layout to landscape mode. Preview your printout before you actually print it out to save paper. Double check your document to make sure there is no word wrap. Your printout should never include word-wrap. If you do see a line wrapping in the print-out, go back and correct the line and re-print your list file. Print your list file. Now single step your program noting how the change input modify the registers. Use the step over button to skip over the subroutine call instructions. This button tells the simulator to run the code in the subroutine without showing you. 22

23 Follow the instructions in Lab 1 "Debug Workshop 1" to simulate your program and verify your program reads the switches and moves them to register r7. Until you actually build your own proto-shield you will have to assume that my WriteDisplay subroutine works. Design Challenge (2 points) You can skip this section if you are happy receiving a passing or even a good grade on the lab. If you want to receive an excellent grade you will need to accept the challenge. Specifically, the maximum grade you can receive on this lab if you do not accept the challenge is 18 points. The purpose of this design challenge is to help you better understand how the I/O ports work and to how the subroutines ReadSwitches and WriteDisplay are written. The SPI Shield which you will be assembling soon has two green status LEDs. They are connected to the two least significant bits of PORTB, as shown in Figure 9. The design challenge for Lab 1 is to create software wires between switches 5 and 4, connected to PINC5 and PINC4, and these two green LEDs. Figure 9 - SPI Shield Schematic Detail This can be accomplished by implementing something similar to the ReadSwitches subroutine, where the inputs are read from the desired I/O port and then written to the output I/O port. Refer to Appendix A for an explanation of how the InitShield and ReadSwitches subroutines work. Note that if you are correctly calling the InitShield subroutine, you do not need to modify any of the Data Direction Registers (DDRx). PORTB should look like this if both LEDs are turned on after correct execution of this challenge: 23

24 Figure 10 - Correct configuration of PORTB registers Lab 1 Deliverable(s) STOP Read the Lab READ ME document contained in the Labs Folder. Be absolutely sure you have followed all instruction in the "Lab Formatting section of this document. Points will be deducted if you do not follow these instructions. You have been warned. If you have not done so already, please purchase a Lab Notebook. Follow the guidelines provided in the Lab Notebook section of the Lab READ ME document. Make sure you have read and understand the Plagiarism section of the Lab READ ME document, especially if you are repeating the class. All labs should represent your own work - DO NOT COPY. Checklist Remember before you turn in your lab Does your software program wire the switches to the 8 discrete LEDs and the 7 segment display? 2. Your lab report includes a title page with your picture (one that will allow me to match a name with a face), lab number, your name, today s date, and the day your lab meets 3. The above information is duplicated in the title block of your assembly program as described in the lab. Do not forget to include the first line of your program containing the title of the lab. If you are not careful this line may be deleted and points deducted. 4. Your list file should include the AVR Studio Assembler version and time stamp. 5. Your list file should not include material from the m328pdef.inc or spi_shield libraries or Resource Use Information. 6. Include the Assembly line indicating that your Assembly program contains no errors or warning in syntax. 7. Your list file should be formatted as defined here. Font: Courier or Courier New Size: 9 to 10.5 point Paragraph Spacing: 0 pt before and after Line Spacing: Single 8. All fields within the program area (address, machine instruction, label, operand, destination operand, source operand, comment) must be aligned. 9. Your list file printout should be in landscape and not have any lines wrap from one line to the next. 10. Never turn in a program that is not debugged (i.e., contains logical errors). 24

25 Appendix A: A Quick Look at SPI_Shield To look at the assembly code in spi_shield.inc; inside the Project window, double-click the spi.inc file in the Included Files folder. You may need to reassemble folder is empty. the program if the You should now be able to tab between the Lab2.asm (named ProtoShieldDemo in the screen capture) and spi_shield.inc files open in the Workspace window. In the Workspace window select the Lab2.asm tab to view this file. How the InitShield Subroutine Initializes the GPIO Ports C and D We begin by initializing PORT D bits 7 to 6 and PORT C bits 5 to 0 as inputs with pull-up resistors. To find out the correct bit settings study Table 1 "Port Pin Configurations." Table 1 Port Pin Configurations DDRXn PORTXn I/O Pull-up Comments 0 0 Input No Read "Synchronized" PINXn 0 1 Input Yes 1 X Output N/A Write bit to PORTXn In this lab we want to configure 8 switches so a byte wide solution makes the most since. The Set Bit(s) in Register (sbr) and Clear Bit(s) in Register (cbr) assembly instructions provide us with our 8-bit solution. The sbr and cbr work with registers, so we will have to first load the Data Direction registers (DDRC, DDRD) and PORT (PORTC, PORTD) registers into one of our 32 general purpose registers, before you can set or clear any of the bits. The sbr, cbr give us 25

26 the ability to set or clear multiple bits. This is done by setting the bit you want set or cleared to 1, with 0 indicating don't change. Reviewing Figure 1 you will notice switches 7 and 6 are wired to Port D bits 7 and 6 and switches 5 to 0 are wired to Port C bits 5 to 0. Consequently, it is these bits within the two Ports that we want to configure as required by Table 1 "Port Pin Configurations." Study the comments following each of the instructions below to see how this was done. ; Initialize Switches with Pull-up resistors and Test LEDs in r16,ddrc // input Port C DDR (0x07) for switches 5 to 0 cbr r16,0b // define bits 5 to 0 as input (clear bit reg.) out DDRC,r16 // output in r16,portc // input Port C Reg. (0x08) for switches 5 to 0 sbr r16,0b // add pull-up resistors (PUR) out PORTC,r16 // output in r16,ddrd // input Port D DDR (0x0A) for switches 7 to 6 cbr r16,0b // define bits 7 to 6 as input (clear) out DDRD,r16 // output in r16,portd // input Port D Reg. (0x0B) for switches 7 to 6 sbr r16,0b // add pull-up resistors (PUR) out PORTD,r16 // output How ReadSwitches Subroutine Maps the 8 Switches to General Purpose Register 6 In this section I am going to show you how I wrote the code to wire the 8 switches to their corresponding bits in Register 6. This virtual connection of the switches to Register 6 is illustrated on the left hand side (in purple) in Figure 1. Looking at Figure 1 you will notice that while switches 7 and 6 are wired to Port D bits 7 and 6, switches 5 to 0 are wired to Port C bits 5 to 0. Consequently, I needed to read the pins of both ports and then concatenate bits 7 and 6 of Port D with bits 5 to 0 of Port C. loop: ; SPI Software Wires in r17, PINC // input port C pins (0x06) into register r17 in r16, PIND // input port D pins (0x09) into register r16 Before I could concatenate (combine) the two registers I needed to clear the unused bits. The Clear Bit(s) in Register (cbr) assembly instructions works perfectly when you want to selectively clear more than one bit while not modifying other bits within the destination register. cbr r17, 0b // clear non-switch bits 7 and 6 cbr r16, 0b // clear non-switch bits 5 to 0 26

27 The notation 0b tells the assembler that the following bits are in binary. So 0b = I could just as easily have typed 0xC0. In this case I used binary to more easily show which bits were being cleared (a 1 is placed in the position to be cleared) and which were not being modified (a 0 is placed in the position to not be modified). Finally, I was ready to combine the bits. The logical or operator is used to accomplish this goal. Reviewing what you learned in your Digital Logic Design class. x Y x or y Because I had set to 0 the bits to be set or cleared by the other register, we only need to look at the first two lines in the table to see how it works. If the target bit is 0 it will remain 0 and if it is 1 it will remain 1. After we have merged our two registers we move the result into register 6 as required by Figure 1. or r16, r17 // concatenate switches SW7 - SW6 : SW5 - SW0 mov r6, r16 // move to standardized switch register Appendix B How the Parts of the Arduino Proto- Shield Work This appendix was written by Bryan Everett, and is designed for the student who does not want to wait to find out how the proto-shield works. In addition to this material you may also want to read "ATmega328P Serial Communications", a pdf document available on my website and Section 18 "SPI -Serial Peripheral Interface" in the ATMEL doc8161.pdf document. The 74HC595 Shift Register The 74HC595 is a high speed CMOS shift register. It has one serial data input with eight (8) parallel output. In this section we will learn how each of these pins control the 74HC595 shift register and what is going on inside the "595" 27

28 Simplified Shift Register Let s discuss the components that make up the 74HC595 shift register. Tri-State Output Buffers The eight parallel-out pins of this shift register are driven by tri-state buffers. A tri-state buffer is a device commonly used on shift registers, memory, and many other kinds of integrated circuits. 28

29 The tri-state buffer shown above has two inputs, data (X) and control (E), which control the state of the output (Y). Just as the name implies, there are three output states: high, low and high impedance. When the pin labeled "E" is high, the output is equal to the input (Y=X). Not very interesting, right? Well, when the pin labeled "E" is low, the output is in high impedance mode. In high impedance mode, the output is virtually disconnected from the input, neither high nor low. The basic operation of a tri-state buffer can also be easily understood if compared to a switch. When the "E" pin is high, the switch is closed, and when the "E" pin is low, the switch is open. In the context of our shift register, the output pins will either contain our data or will be in high impedance mode. For more information regarding tri-state buffers, click here. National Semiconductor - Tri-State Buffer IC Storage Registers (D-Flip Flops) Looking further into our shift register we see the storage registers. These registers are made up of D-type flip flops. The D-type flip flop is capable of storing one bit of memory. The D-flip flop's function is to place on the output whatever data is on its input when the flip flop detects a rising edge signal (input buffer inverts clock before input of FF shown) on the clock port. This works by placing the data to be stored (1 or 0) on the D pin. Once the data is on the D line, the clock pin must be pulsed high. On the rising edge of the pulse the data on the D pin will appear on the Q pin. 29

30 In context to our shift register, when the data appears on D pins of the storage registers and is ready to be displayed, the clock pin is pulsed and the data is sent to the tri-state buffers. For more information regarding D-type flip flops, click here. Fairchild Semiconductors - D-Flip Flop Shift Registers (D-Flip Flops) The shift registers are final stage and are made up of D-Flip flops as well. These are the heart of our 74HC595 shift register. Below is a simplified version of what makes our shift registers work. What we have there is two D-type shift registers. The output of the first D flip flop is connected to the input of the second D flip flop. The clock pins are connected together on all D flip flops. To understand how this shift register works, we will look at a two bit shift register: Suppose we want to set Q2 high and Q1 low: 1. The D pin is set high. 2. The clock pin is pulsed high once. (This makes the output Q1 high. Q1 is connected to the input of the second D flip flop) 3. The D pin is brought low. 4. The clock is pulsed once again. 5. The result is Q1 = 0 and Q2 = 1. 30

31 The above example only covers a two bit shift register. Below is the logic diagram of our 74HC595 8-bit shift register. 31

32 32

33 MM74HC595 Logical Diagram by Fairchild Semiconductor Below is the timing diagram of our 74HC595 8-bit shift register. MM74HC595 by Fairchild Semiconductors For more information regarding shift registers, see AllAboutCircuits.com 33

34 Seven Segment Display Just as you learned in EE-201, seven segment displays made up of seven (eight with a decimal point) LEDs arranged and shaped such that numbers between 0 and 9 can be displayed. There are two basic kinds of seven segment displays, common anode and common cathode. This simply means that they share either a supply or ground connection. Other than that, these seven segment displays function just as seven separate LEDs. The Arduino Proto-Shield uses a common cathode display. Source: ElectronicsLab - Common Anode. Each of the segments includes a 1 Kohm resistor to limit current though the LED. The resister values are calculated by: (VDD - VLED)/ILED. Since the segments function as individual LEDs, see LED Basics for more information. Appendix C Reference 1. Here is a New York University (NYU) lab for the 74hc595 shift register and the Arduino: 2. Serial to Parallel Shifting-Out with a 74HC595, HC595 Data Sheet: 8-bit serial-in, serial or parallel-out shift register with output latches; 3-state multiplying arduino outputs/inputs 4. Atmel ATmega328 datasheet doc2545.pdf, Section 16 SPI Serial Peripheral Interface (pages 160 to 162) 5. Atmel AVR Microcontroller Primer: Programming and Interfacing by Steven F. Barrett, Section Serial Peripheral Interface (pages 34 to 39[1] 34

35 6. Programming and Customizing the AVR Microcontroller by Dhananjay Gadre, Section I/O Expansion using Shift Register (page 110 to 1111) 7. Embedded C Programming and The Atmel AVR 2nd Edition by Richard H. Barnett, Section 2.10 Serial Communication using the SPI (page 151 to 157[2]) 8. University of Maryland - Tri-state Buffer 9. Hobby Projects - D-type Flip Flop [1] Assumes ATmega16 [2] Assumes ATMega16 and ATMega128 35

READING SOURCE MATERIAL

READING SOURCE MATERIAL 1 P a g e General-Purpose Input/Output READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 4: AVR I/O Port Programming

More information

COMP2121 Experiment 4

COMP2121 Experiment 4 COMP2121 Experiment 4 1. Objectives In this lab, you will learn AVR programming on Parallel input/output; Some typical input/output devices; and Interrupts 2. Preparation Before coming to the laboratory,

More information

Lab 2: Basic Assembly Programming and Debugging using AVR Studio. Due: December 13, 2011

Lab 2: Basic Assembly Programming and Debugging using AVR Studio. Due: December 13, 2011 Lab 2: Basic Assembly Programming and Debugging using AVR Studio 1 Outcomes Due: December 13, 2011 Familiarize yourself with the capabilities of the ATMEGA32 embedded microcontroller and AVR Studio Develop

More information

Register-Level Programming

Register-Level Programming Introduction Register-Level Programming Programming can be considered a set a instructions that are executed in a precise order. A programming simulator can evaluate how instructions store, move and calculate

More information

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017 Objectives The AVR microcontroller and embedded systems using assembly and c I/O Ports in AVR List all the ports of the AVR microcontroller Describe the dual role of the AVR pins Code assembly language

More information

NEWBIE'S GUIDE TO AVR DEVELOPMENT A N IN TR O DU CT I O N I N TE N DE D FO R PEOPL E W I TH NO PRIOR AV R KNOWLE DG E AVRFREAKS.

NEWBIE'S GUIDE TO AVR DEVELOPMENT A N IN TR O DU CT I O N I N TE N DE D FO R PEOPL E W I TH NO PRIOR AV R KNOWLE DG E AVRFREAKS. NEWBIE'S GUIDE TO AVR DEVELOPMENT A N IN TR O DU CT I O N I N TE N DE D FO R PEOPL E W I TH NO PRIOR AV R KNOWLE DG E AVRFREAKS.NET JULY 2002 TABLE OF CONTENTS Newbie's Getting Started Guide...2 Preparing

More information

Buses and Parallel Input/Output

Buses and Parallel Input/Output Buses and Parallel Input/Output Lecturer: Sri Parameswaran Notes by: Annie Guo Week7 1 Lecture Overview Buses Computer buses I/O Addressing Memory mapped I/O Separate I/O Parallel input/output AVR examples

More information

Logic Instructions and Programs READING

Logic Instructions and Programs READING 1 P a g e Logic Instructions and Programs READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 5: Arithmetic, Logic

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (I)

COMP2121: Microprocessors and Interfacing. I/O Devices (I) COMP2121: Microprocessors and Interfacing I/O Devices (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview I/O Ports AVR Ports 2 2 What is I/O? I/O is Input or Output (Input/Output).

More information

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language)

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language) 3 AVR (AVR Assembly Language). ก ก ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load register

More information

IAS0430 MICROPROCESSOR SYSTEMS

IAS0430 MICROPROCESSOR SYSTEMS IAS0430 MICROPROCESSOR SYSTEMS Fall 2018 Arduino and assembly language Martin Jaanus U02-308 martin.jaanus@ttu.ee 620 2110, 56 91 31 93 Learning environment : http://isc.ttu.ee Materials : http://isc.ttu.ee/martin

More information

EE 109 Unit 4. Microcontrollers (Arduino) Overview

EE 109 Unit 4. Microcontrollers (Arduino) Overview 1 EE 109 Unit 4 Microcontrollers (Arduino) Overview 2 Using software to perform logic on individual (or groups) of bits BIT FIDDLING 3 Numbers in Other Bases in C/C++ Suppose we want to place the binary

More information

AVR. (AVR Assembly Language) Assembler . ก ก

AVR. (AVR Assembly Language) Assembler . ก ก AVR (AVR Assembly Language). ก ก Assembler 2 1 ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load

More information

Lab3: I/O Port Expansion

Lab3: I/O Port Expansion Page 1/6 Revision 0 26-Jan-16 OBJECTIVES Explore and understand the implementation of memory-mapped I/O. Add an 8-bit input port and an 8-bit output port. REQUIRED MATERIALS EEL 3744 (upad and upad Proto

More information

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014 CMPE 311 - C Programming & Embedded Systems Discussion I (Version 2.0) August 31, 2014 Version History Version 2.1 - (August 31, 2015) - Addition Pin Connections Section and Document Verification. Version

More information

7 8 9 C. PRELAB REQUIREMENTS You must adhere to the Lab Rules and Policies document for every lab.

7 8 9 C. PRELAB REQUIREMENTS You must adhere to the Lab Rules and Policies document for every lab. Page 1/ Revision 1 OBJECTIVES To understand how a keypad functions as a raster scan input device and to learn how to interface a keypad to a microprocessor. Further explore and understand the implementation

More information

(Refer Slide Time: 1:40)

(Refer Slide Time: 1:40) Computer Architecture Prof. Anshul Kumar Department of Computer Science and Engineering, Indian Institute of Technology, Delhi Lecture - 3 Instruction Set Architecture - 1 Today I will start discussion

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

REQUIRED MATERIALS Epiphany-DAQ board Wire Jumpers Switch LED Resistors Breadboard Multimeter (if needed)

REQUIRED MATERIALS Epiphany-DAQ board Wire Jumpers Switch LED Resistors Breadboard Multimeter (if needed) Page 1/6 Lab 1: Intro to Microcontroller Development, 06-Jan-16 OBJECTIVES This lab will introduce you to the concept of developing with a microcontroller while focusing on the use of General Purpose Input/Output

More information

Teacher Activity: page 1/9 Mathematical Expressions in Microsoft Word

Teacher Activity: page 1/9 Mathematical Expressions in Microsoft Word Teacher Activity: page 1/9 Mathematical Expressions in Microsoft Word These instructions assume that you are familiar with using MS Word for ordinary word processing *. If you are not comfortable entering

More information

(Refer Slide Time: 1:43)

(Refer Slide Time: 1:43) (Refer Slide Time: 1:43) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology, Madras Lecture - 27 Pattern Detector So, we talked about Moore

More information

Introduction to Assembly language

Introduction to Assembly language Introduction to Assembly language 1 USING THE AVR MICROPROCESSOR Outline Introduction to Assembly Code The AVR Microprocessor Binary/Hex Numbers Breaking down an example microprocessor program AVR instructions

More information

Elec 326: Digital Logic Design

Elec 326: Digital Logic Design Elec 326: Digital Logic Design Project Requirements Fall 2005 For this project you will design and test a three-digit binary-coded-decimal (BCD) adder capable of adding positive and negative BCD numbers.

More information

Lab3: I/O Port Expansion

Lab3: I/O Port Expansion Page 1/5 Revision 2 6-Oct-15 OBJECTIVES Explore and understand the implementation of memory-mapped I/O. Add an 8-bit input port and an 8-bit output port. REQUIRED MATERIALS EEL 3744 (upad and upad Proto

More information

4X4 Driver Shield Manual

4X4 Driver Shield Manual 3/31/2012 4X4 Driver Shield Manual High current, high side switching for Arduino Logos Electromechanical 4X4 Driver Shield Manual High current, high side switching for Arduino Introduction The Logos Electromechanical

More information

Embedded programming, AVR intro

Embedded programming, AVR intro Applied mechatronics, Lab project Embedded programming, AVR intro Sven Gestegård Robertz Department of Computer Science, Lund University 2017 Outline 1 Low-level programming Bitwise operators Masking and

More information

CSI Lab 02. Tuesday, January 21st

CSI Lab 02. Tuesday, January 21st CSI Lab 02 Tuesday, January 21st Objectives: Explore some basic functionality of python Introduction Last week we talked about the fact that a computer is, among other things, a tool to perform high speed

More information

Writing Code and Programming Microcontrollers

Writing Code and Programming Microcontrollers Writing Code and Programming Microcontrollers This document shows how to develop and program software into microcontrollers. It uses the example of an Atmel ATmega32U2 device and free software. The ATmega32U2

More information

ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O

ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O ECE2049-E17 Lecture 4 1 ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O Administrivia Homework 1: Due today by 7pm o Either place in box in ECE office or give to me o Office hours tonight!

More information

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

Pre-Lab: Part 1 Using The Development Environment. Purpose: Minimum Parts Required: References: Handouts:

Pre-Lab: Part 1 Using The Development Environment. Purpose: Minimum Parts Required: References: Handouts: Purpose: Minimum Parts Required: References: Handouts: Laboratory Assignment Number 1 for Mech 143/ELEN123 Due by 5:00pm in lab box on Friday, April 19, 2002 Pre-Lab due by 5:00pm in lab box on Tuesday,

More information

NIOS CPU Based Embedded Computer System on Programmable Chip

NIOS CPU Based Embedded Computer System on Programmable Chip 1 Objectives NIOS CPU Based Embedded Computer System on Programmable Chip EE8205: Embedded Computer Systems This lab has been constructed to introduce the development of dedicated embedded system based

More information

Finite State Machine Lab

Finite State Machine Lab Finite State Machine Module: Lab Procedures Goal: The goal of this experiment is to reinforce state machine concepts by having students design and implement a state machine using simple chips and a protoboard.

More information

Serial versus Parallel Data Transfers

Serial versus Parallel Data Transfers Serial versus Parallel Data Transfers 1 SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Serial communications Most communications is carried out over serial links Fewer wires needed Less electronics

More information

Laboratory 10. Programming a PIC Microcontroller - Part II

Laboratory 10. Programming a PIC Microcontroller - Part II Laboratory 10 Programming a PIC Microcontroller - Part II Required Components: 1 PIC16F88 18P-DIP microcontroller 1 0.1 F capacitor 3 SPST microswitches or NO buttons 4 1k resistors 1 MAN 6910 or LTD-482EC

More information

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16 Page 1/14 Quartus Tutorial with Basic Graphical Gate Entry and Simulation Example Problem Given the logic equation Y = A*/B + /C, implement this equation using a two input AND gate, a two input OR gate

More information

Lesson 4 Fun with W and F

Lesson 4 Fun with W and F Elmer 160 Lesson 4 Overview Lesson 4 Introduction In this section This lesson introduces the first few PIC instructions. The following is a list of topics in this section: Description See Page Writing

More information

Word: Print Address Labels Using Mail Merge

Word: Print Address Labels Using Mail Merge Word: Print Address Labels Using Mail Merge No Typing! The Quick and Easy Way to Print Sheets of Address Labels Here at PC Knowledge for Seniors we re often asked how to print sticky address labels in

More information

Chapter 1 Microprocessor architecture ECE 3120 Dr. Mohamed Mahmoud http://iweb.tntech.edu/mmahmoud/ mmahmoud@tntech.edu Outline 1.1 Computer hardware organization 1.1.1 Number System 1.1.2 Computer hardware

More information

Microprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur

Microprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur Microprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur Lecture - 09 8085 Microprocessors (Contd.) (Refer Slide Time:

More information

EE 231 Fall Lab 2: Decoders and Multiplexers. Introduction

EE 231 Fall Lab 2: Decoders and Multiplexers. Introduction Lab 2: Decoders and Multiplexers Introduction Decoders and multiplexers are important combinational circuits in many logic designs. Decoders convert n inputs to a maximum of unique 2 n outputs. A special

More information

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

ENCM 369 Winter 2019 Lab 6 for the Week of February 25 page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM

More information

Chapter 4. MARIE: An Introduction to a Simple Computer

Chapter 4. MARIE: An Introduction to a Simple Computer Chapter 4 MARIE: An Introduction to a Simple Computer Chapter 4 Objectives Learn the components common to every modern computer system. Be able to explain how each component contributes to program execution.

More information

Digital Electronics & Computer Engineering (E85)

Digital Electronics & Computer Engineering (E85) Digital Electronics & Computer Engineering (E85) Lab 4: Thunderbird Turn Signal Introduction In this lab, you will design a finite state machine to control the taillights of a 1965 Ford Thunderbird 1 and

More information

Microcontroller Systems

Microcontroller Systems µcontroller systems 1 / 43 Microcontroller Systems Engineering Science 2nd year A2 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/2co Michaelmas 2014 µcontroller

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

MAPLOGIC CORPORATION. GIS Software Solutions. Getting Started. With MapLogic Layout Manager

MAPLOGIC CORPORATION. GIS Software Solutions. Getting Started. With MapLogic Layout Manager MAPLOGIC CORPORATION GIS Software Solutions Getting Started With MapLogic Layout Manager Getting Started with MapLogic Layout Manager 2011 MapLogic Corporation All Rights Reserved 330 West Canton Ave.,

More information

EE251: Thursday September 20

EE251: Thursday September 20 EE251: Thursday September 20 Parallel I/O aka General Purpose I/O aka GPIO Common Devices: Switches, LEDs, Keypads Read Lab 4 carefully, and Chapter 14 in text Think about what you would like to review

More information

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE: 1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE: A microprocessor is a programmable electronics chip that has computing and decision making capabilities similar to central processing unit

More information

Creating a Brochure in Publisher

Creating a Brochure in Publisher Creating a Brochure in Publisher If you closed the Flyer, as indicated above, you will see the Microsoft Publisher Task Pane on the left side of your screen. Click the Brochures selection in the Publication

More information

Introduction to AVR Assembly Language Programming

Introduction to AVR Assembly Language Programming 1 P a g e Introduction to AVR Assembly Language Programming READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 0:

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 3170 Microcontroller Applications Lecture 4 : Processors, Computers, and Controllers - 1.2 (reading assignment), 1.3-1.5 Based on slides for ECE3170 by Profs. Kieckhafer, Davis, Tan, and Cischke Outline

More information

COMP2121 Introductory Experiment

COMP2121 Introductory Experiment COMP2121 Introductory Experiment Objectives: In this introductory experiment, you will: Learn how to use AVR studio, an Integrated Development Environment (IDE) for developing AVR applications in Windows

More information

EE261 Computer Project 1: Using Mentor Graphics for Digital Simulation

EE261 Computer Project 1: Using Mentor Graphics for Digital Simulation EE261 Computer Project 1: Using Mentor Graphics for Digital Simulation Introduction In this project, you will begin to explore the digital simulation tools of the Mentor Graphics package available on the

More information

Lab 7: RPN Calculator

Lab 7: RPN Calculator University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory Lab 7: RPN Calculator The purpose of this lab is: Purpose 1. To get familiar with the use

More information

(Refer Slide Time: 01:25)

(Refer Slide Time: 01:25) Computer Architecture Prof. Anshul Kumar Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture - 32 Memory Hierarchy: Virtual Memory (contd.) We have discussed virtual

More information

Assembly Programming in Atmel Studio 7 Step by Step Tutorial

Assembly Programming in Atmel Studio 7 Step by Step Tutorial Assembly Programming in Atmel Studio 7 Step by Step Tutorial Sepehr Naimi BIHE University 12/1/2017 Contents Introduction... 2 Downloading and Installing Atmel Studio... 3 Opening Atmel Studio... 3 Creating

More information

Using MS Publisher. Launch MS Publisher: Start > All Programs > Microsoft Office > Publisher. Setting up Document Size and Orientation

Using MS Publisher. Launch MS Publisher: Start > All Programs > Microsoft Office > Publisher. Setting up Document Size and Orientation Designing and Creating your GIS Poster Revised by Carolyn Talmadge 1/20/2015 First think about your audience and purpose then design your poster! Here are instructions for setting up your poster using

More information

Copyright 2011 R.S.R. Electronics, Inc. All rights reserved. 04/11. Ver. 1.0web

Copyright 2011 R.S.R. Electronics, Inc. All rights reserved. 04/11. Ver. 1.0web For XILINX WebPack Copyright 2011 R.S.R. Electronics, Inc. All rights reserved. 04/11 Ver. 1.0web 1 Table of Contents 1.0 INTRODUCTION...3 2.0 GENERAL DESCRIPTION...5 3.0 BRIEF DESCRIPTION Of PLDT-3 BOARD...6

More information

Input/Output Ports and Interfacing

Input/Output Ports and Interfacing Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning Basic I/O Concepts Peripherals such as LEDs and keypads are essential

More information

Physics 335 Intro to MicroControllers and the PIC Microcontroller

Physics 335 Intro to MicroControllers and the PIC Microcontroller Physics 335 Intro to MicroControllers and the PIC Microcontroller May 4, 2009 1 The Pic Microcontroller Family Here s a diagram of the Pic 16F84A, taken from Microchip s data sheet. Note that things are

More information

CSCE 436/836: Embedded Systems Lab 1b: Hoverboard Programming Introduction

CSCE 436/836: Embedded Systems Lab 1b: Hoverboard Programming Introduction 1 Overview CSCE 436/836: Embedded Systems Lab 1b: Hoverboard Programming Introduction Instructor: Carrick Detweiler carrick _at_ cse.unl.edu University of Nebraska-Lincoln Spring 2011 Started: Jan 27,

More information

ELEG3924 Microprocessor

ELEG3924 Microprocessor Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.2 Assembly Language Programming Dr. Jing Yang jingyang@uark.edu 1 OUTLINE Inside 8051 Introduction to assembly programming

More information

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits Equipment and Components Quartus software and Altera DE2-115 board PART 1: Number Representation in Microsoft Calculator. First, let s

More information

Lab Objectives. 2. Preparations. 3. Signing in. 4. Examining the Host Environment. 5. Part A: Introduction to AVR Studio. 5.

Lab Objectives. 2. Preparations. 3. Signing in. 4. Examining the Host Environment. 5. Part A: Introduction to AVR Studio. 5. Lab 0 1. Objectives Learn how to use AVR studio, an Integrated Development Environment (IDE) for developing AVR applications in Windows environments, to debug and run an AVR assembly program. Understand

More information

Introduction to PSpice

Introduction to PSpice Introduction to PSpice Simulation Software 1 The Origins of SPICE In the 1960 s, simulation software begins CANCER Computer Analysis of Nonlinear Circuits, Excluding Radiation Developed at the University

More information

MAPLOGIC CORPORATION. GIS Software Solutions. Getting Started. With MapLogic Layout Manager

MAPLOGIC CORPORATION. GIS Software Solutions. Getting Started. With MapLogic Layout Manager MAPLOGIC CORPORATION GIS Software Solutions Getting Started With MapLogic Layout Manager Getting Started with MapLogic Layout Manager 2008 MapLogic Corporation All Rights Reserved 330 West Canton Ave.,

More information

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: This lab will introduce basic embedded systems programming concepts by familiarizing the user with an embedded programming

More information

Word Tips (using Word but these work with Excel, PowerPoint, etc) Paul Davis Crosslake Communications

Word Tips (using Word but these work with Excel, PowerPoint, etc) Paul Davis Crosslake Communications Word Tips (using Word but these work with Excel, PowerPoint, etc) Paul Davis Crosslake Communications What tips are we going to discuss? First of all, HELP Fonts Tables Columns Pasting Images Mail Merge

More information

Memory Supplement for Section 3.6 of the textbook

Memory Supplement for Section 3.6 of the textbook The most basic -bit memory is the SR-latch with consists of two cross-coupled NOR gates. R Recall the NOR gate truth table: A S B (A + B) The S stands for Set to remember, and the R for Reset to remember.

More information

Introduction. Purpose. Intended Audience. Conventions. Close

Introduction. Purpose. Intended Audience. Conventions. Close Introduction Introduction Verilog-XL is a simulator that allows you to test the logic of a design. The process of logic simulation in Verilog-XL is as follows: 1. Describe the design to Verilog-XL. 2.

More information

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

ELEG3923 Microprocessor Ch.2 Assembly Language Programming Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.2 Assembly Language Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Inside 8051 Introduction to assembly programming

More information

BASICS OF THE RENESAS SYNERGY TM

BASICS OF THE RENESAS SYNERGY TM BASICS OF THE RENESAS SYNERGY TM PLATFORM Richard Oed 2018.11 02 CHAPTER 9 INCLUDING A REAL-TIME OPERATING SYSTEM CONTENTS 9 INCLUDING A REAL-TIME OPERATING SYSTEM 03 9.1 Threads, Semaphores and Queues

More information

Lab 4: Digital Electronics BMEn 2151 Introductory Medical Device Prototyping Prof. Steven S. Saliterman

Lab 4: Digital Electronics BMEn 2151 Introductory Medical Device Prototyping Prof. Steven S. Saliterman Lab 4: Digital Electronics BMEn 2151 Introductory Medical Device Prototyping Prof. Steven S. Saliterman Exercise 4-1: Familiarization with Lab Box Contents & Reference Books 4-1-1 CMOS Cookbook (In the

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Lecture 12 Some Hardware Considerations Hardware Considerations Slide 1 Logic States Digital signals may be in one of three states State 1: High, or 1. Using positive logic

More information

Part 1 Using Serial EEPROMs

Part 1 Using Serial EEPROMs Part 1 Using Serial EEPROMs copyright 1997, 1999 by Jan Axelson If you have a project that needs a modest amount of nonvolatile, read/write memory, serial EEPROM may be the answer. These tiny and inexpensive

More information

Excel Select a template category in the Office.com Templates section. 5. Click the Download button.

Excel Select a template category in the Office.com Templates section. 5. Click the Download button. Microsoft QUICK Excel 2010 Source Getting Started The Excel Window u v w z Creating a New Blank Workbook 2. Select New in the left pane. 3. Select the Blank workbook template in the Available Templates

More information

BASICS OF THE RENESAS SYNERGY PLATFORM

BASICS OF THE RENESAS SYNERGY PLATFORM BASICS OF THE RENESAS SYNERGY PLATFORM TM Richard Oed 2017.12 02 CHAPTER 9 INCLUDING A REAL-TIME OPERATING SYSTEM CONTENTS 9 INCLUDING A REAL-TIME OPERATING SYSTEM 03 9.1 Threads, Semaphores and Queues

More information

(Refer Slide Time 6:48)

(Refer Slide Time 6:48) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 8 Karnaugh Map Minimization using Maxterms We have been taking about

More information

Module 2: Introduction to AVR ATmega 32 Architecture

Module 2: Introduction to AVR ATmega 32 Architecture Module 2: Introduction to AVR ATmega 32 Architecture Definition of computer architecture processor operation CISC vs RISC von Neumann vs Harvard architecture AVR introduction AVR architecture Architecture

More information

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 GETTING STARTED PAGE 02 Prerequisites What You Will Learn MORE TASKS IN MICROSOFT EXCEL PAGE 03 Cutting, Copying, and Pasting Data Basic Formulas Filling Data

More information

How to Create Custom Name Badge Inserts with a Mail Merge in Microsoft Word 2007

How to Create Custom Name Badge Inserts with a Mail Merge in Microsoft Word 2007 Many people know that you can use the Mail Merge feature in Microsoft Word 2007 to easily create mailing labels, but did you know you can use it to quickly create custom name badge inserts? Here, you will

More information

Micro-Controllers. Module 2: Outputs Control and Inputs Monitoring. IAT Curriculum Unit PREPARED BY. August 2008

Micro-Controllers. Module 2: Outputs Control and Inputs Monitoring. IAT Curriculum Unit PREPARED BY. August 2008 Micro-Controllers Module 2: Outputs Control and Inputs Monitoring PREPARED BY IAT Curriculum Unit August 2008 Institute of Applied Technology, 2008 2 Module 2: Outputs Control and Inputs Monitoring Module

More information

Creating and Simulate/Emulating an ASM Project in Atmel Introduction Procedure File New Project Assembler

Creating and Simulate/Emulating an ASM Project in Atmel Introduction Procedure File New Project Assembler Page 1/9 Revision 0 Introduction The purpose of this document is to enable a student to quickly create a project under Atmel Studio, to simulate the program, and then to emulate the program. To complete

More information

RIS shading Series #2 Meet The Plugins

RIS shading Series #2 Meet The Plugins RIS shading Series #2 Meet The Plugins In this tutorial I will be going over what each type of plugin is, what their uses are, and the basic layout of each. By the end you should understand the three basic

More information

Getting Started with STK200 Dragon

Getting Started with STK200 Dragon Getting Started with STK200 Dragon Introduction This guide is designed to get you up and running with main software and hardware. As you work through it, there could be lots of details you do not understand,

More information

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut Arduino 05: Digital I/O Jeffrey A. Meunier jeffm@engr.uconn.edu University of Connecticut About: How to use this document I designed this tutorial to be tall and narrow so that you can read it on one side

More information

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming ICT 6641: Advanced Embedded System Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming Prof. S. M. Lutful Kabir Session: April, 2011 Review on Lecture-1 Three parts of a computer : CPU, Memory

More information

New, standard features of DesignMerge Pro!

New, standard features of DesignMerge Pro! Layout & Imposition Options New, standard features of DesignMerge Pro! The latest release of DesignMerge Pro now includes a new set of Layout and Imposition features that can be used to streamline your

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Review Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA February 15, 2018 Aly El-Osery (NMT) EE 308:

More information

Project 3: RPN Calculator

Project 3: RPN Calculator ECE267 @ UIC, Spring 2012, Wenjing Rao Project 3: RPN Calculator What to do: Ask the user to input a string of expression in RPN form (+ - * / ), use a stack to evaluate the result and display the result

More information

EE 231 Fall EE 231 Lab 3. Decoders and Multiplexers. Figure 1: 7-Segment Display. Memory: where the program is stored.

EE 231 Fall EE 231 Lab 3. Decoders and Multiplexers. Figure 1: 7-Segment Display. Memory: where the program is stored. EE 231 Lab 3 Decoders and Multiplexers Decoders and multiplexers are important combinational circuits in many logic designs. Decoders convert n inputs to a maximum of unique 2 n outputs. A special case

More information

Table of Contents. How to use this document. How to use the template. Page 1 of 9

Table of Contents. How to use this document. How to use the template. Page 1 of 9 Table of Contents How to use this document... 1 How to use the template... 1 Template Sections... 2 Blank Section... 2 Signature Sheet... 2 Title Page... 2 Roman Numerals Section (i, ii, iii, iv )... 3

More information

SH69P48A EVB. Application Notes for SH69P48A EVB SH69V48A JP2 J4(ICE_J4) S1 IDD TEST JP1 74HC273 JP4 JP3 74HC273 JP6 STKOVE JP7 SW1 J5(ICE_J5)

SH69P48A EVB. Application Notes for SH69P48A EVB SH69V48A JP2 J4(ICE_J4) S1 IDD TEST JP1 74HC273 JP4 JP3 74HC273 JP6 STKOVE JP7 SW1 J5(ICE_J5) SH69P48A EVB Application Notes for SH69P48A EVB The SH69P48A EVB is used to evaluate the SH69P48A chip's function for the development of application program. It contains of a SH69V48A chip to evaluate

More information

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi 1 P a g e ATmega Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming in Assembly

More information

proj 3B intro to multi-page layout & interactive pdf

proj 3B intro to multi-page layout & interactive pdf art 2413 typography fall 17 proj 3B intro to multi-page layout & interactive pdf objectives Students introduced to pre-made layered mockups that utilized smart art by placing vector artwork into the Photoshop

More information

I2C and SPI Foundation

I2C and SPI Foundation Revision 30 September 2010 Release I2C and SPI Foundation 17 March 2018 changed ref: command f to x Introduction I2C (I squared C) and SPI (Serial peripheral Interface) are two main ways that microcontrollers

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers Memory Map I/O Registers Instruction

More information

Rensselaer Polytechnic Institute Computer Hardware Design ECSE 4770

Rensselaer Polytechnic Institute Computer Hardware Design ECSE 4770 RPI Rensselaer Polytechnic Institute Computer Hardware Design ECSE 4770 Lab Assignment 2 Protoboard Richards Controller and Logic Analyzer Laboratory Rev. C Introduction This laboratory assignment is an

More information

Using Mail Merge in Microsoft Word 2003

Using Mail Merge in Microsoft Word 2003 Using Mail Merge in Microsoft Word 2003 Mail Merge Created: 12 April 2005 Note: You should be competent in Microsoft Word before you attempt this Tutorial. Open Microsoft Word 2003 Beginning the Merge

More information