Announcements Homework #3 due today. Ports. Outline for Today C8051 SFRs & Port I/O Worksheet #4 - simple I/O code. Using Ports

Similar documents
Outline for Today. Lab Equipment & Procedures. Teaching Assistants. Announcements

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.

Magic 8 Ball. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

MICROPROCESSORS A (17.383) Fall Lecture Outline

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2013

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 1.

C Language Programming

Pre-Laboratory #Boolean Expressions ECE 332

CONTENTS BIGAVR2 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

C:\Users\Jacob Christ\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

MICROPROCESSORS A (17.383) Fall Lecture Outline

EECE 690/890 Digital Radio Hardware Design. Team 3 Assignment 2. Informal Design Review: Thurs 10/15/98 Deliverables Due: Tues 10/20/98

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

ELEC 3040/3050 Lab Manual Lab 2 Revised 8/20/14. LAB 2: Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

Real Time Operating Systems Application Board Details

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Laboratory: Introduction to Mechatronics

CONTENTS. dspicpro4 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

ECE 2036 Lab 4 Setup and Test mbed I/O Hardware Check-Off Deadline: Thursday, March 17, Name:

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

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

Microprocessors B Lab 1 Spring The PIC24HJ32GP202

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

Using peripherals on the MSP430 (if time)

AN127 FLASH PROGRAMMING VIA THE C2 INTERFACE. Relevant Devices. Introduction. C2 Interface

Which LED(s) turn on?

Downloaded from Elcodis.com electronic components distributor

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Programming Assignment 1: Pushbutton and Light

University of Texas at El Paso Electrical and Computer Engineering Department

EE251: Thursday November 15

RFID: Read and Display V2010. Version 1.1. Sept Cytron Technologies Sdn. Bhd.

ECE2049: Embedded Systems in Engineering Design Lab Exercise #3 C Term Making a Time and Temperature Display

17. I 2 C communication channel

ECE383: Microprocessors Lab 9 Analog-to-Digital and Digital-to-Analog Conversion with I 2 C Serial EEPROM Data Storage

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

EECE 2411/2211-Introduction to Electrical and Computer Engineering Lab. Lab 3

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Analog Conversion and MAC. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Lab #12: ArithmeticLogic Unit

1.3 Check for solder bridges, flux or other contaminants, or any evidence of cracked or damaged components.

Asynchronous & Synchronous Serial Communications Interface. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Laboratory of Sensors Engineering Sciences 9 CFU

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

CSCB58 - Lab 0. Intro to The Lab & The DE2 Board. Prelab /4 Part I (in-lab) /1 Part II (in-lab) /1

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Lab #2: Building the System

MTRX3700 Mechatronics

Lab 4: Determining temperature from a temperature sensor

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING MSC SYSTEMS ENGINEERING AND ENGINEERING MANAGEMENT SEMESTER 2 EXAMINATION 2016/2017

EE251: Thursday September 20

Which LED(s) turn on? May 4, 2018 E40M Spring 2018 T. Diamandis, J. Plummer, R. Howe, C. Z. Lee 1

Embedded World Television, Radio, CD player, Washing Machine Microwave Oven Card readers, Palm devices

Lecture 2. Silicon Labs C8051F020 System Overview

PRELAB! Read the entire lab, and complete the prelab questions (Q1- Q3) on the answer sheet before coming to the laboratory.

Physics 335 Intro to MicroControllers and the PIC Microcontroller

EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5

BIG8051. Development system. User manual

Using the IDE and ANSI Display Commands. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

ECE 103 In-Class Exercise L1 Guide

Course Outline Introduction to C-Programming

CSCE 312 Lab manual. Lab 4 - Computer Organization and Data Path Design. Instructor: Dr. Yum. Fall 2016

Lecture 5. Defining Functions

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

Which LED(s) turn on? May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 1

LAB #1: The CSM12C32 Module and PBMCUSLK Project Board

None. MICROCONTROLLERS III

Computer Science II Lecture 1 Introduction and Background

Parallel I/O and Keyboard Scanning

Engr 123 Spring 2018 Notes on Visual Studio

Introduction to Microcontrollers

CEIBO FE-51RD2 Development System

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

Calendar Description

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Procedure: Determine the polarity of the LED. Use the following image to help:

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Lab 5: LCD and A/D: Digital Voltmeter

agenda 10 MIN Go over benchmark 30 MIN Unit 2 Day 1 Notes 5 MIN Mastery Work

Technical documentation NLS-3000 NAVIGATION LIGHT CONTROL PANEL

ME456: Mechatronics. Prof. Clark Radcliffe. Do you have the knack? Joonho Lee, TA. What s Mechatronics? Mechatronics

Programming Microcontroller Assembly and C

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

ECE 362 Experiment 3: General Purpose I/O

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

GEORGIA INSTITUTE OF TECHNOLOGY School of Electrical and Computer Engineering ECE 2020 Fall 2017 Lab #1: Digital Logic Module

Proto-DB (#28310): Prototyping Daughterboard

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

PRELAB! Read the entire lab, and complete the prelab questions (Q1-Q3) on the answer sheet before coming to the laboratory.

Instruction and Operation Manual

The Atmel ATmega328P Microcontroller

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 1/19/2018 At the BEGINNING of class)

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 2 Assigned: September 7, 2016 Due: Wednesday, September 14, 2016 by 2:30 pm

CSE3215 Embedded Systems Laboratory

ECE 2036: Lab #3 mbed Hardware Starter Lab Category: Getting Started with MBED ~ 1 week to complete

Transcription:

Announcements Homework #3 due today Online LMS Assessment Everybody submits their own on LMS You should have a lab notebook by now You should have the Lab Manual by now Outline for Today C8051 SFRs & Port I/O Worksheet #4 - simple I/O code Ports Ports are sets of connections on the microcontroller They are used to communicate with the external circuitry (input/output) The C8051 has 8 ports, P0, P1, P7 We will only use Ports P0, P1, P2, and P3 The C8051 manual lists Ports and the use of their pins 2 3 C8051F020 Block Diagram (pg 18) Using Ports Ports 0 7 These input and output pins can be connected to wires where signals are produced Either a sensor will detect something and send a signal to the microcontroller or the microcontroller will send out a signal to control a hardware feature We will show you where you can make these connections using a prototyping board (commonly called a protoboard or bread board) We need a way to read the signals on these pins, send signals out these pins, and configure the system to know which way the system is wired (input or output) 4 5

Special Function Registers Special Function Registers A Special Function Register (SFR) is a microprocessor feature capable of receiving information, holding it, and transferring it. SFRs are used in the C8051 for: Input/Output Control (Configuring pins, A/D, ) C8051 SFRs are listed in the header file: c8051f020.h SFRs have a size of 1 byte (8 bits) The SFRs look like memory locations to the software Counting Timing Bit Identification (One Byte) Arithmetic operations, addressing, 7 6 5 4 3 2 1 0 6 7 Special Function Registers, Ports & Communication Each I/O port has a SFR associated with it Example: P2 is the SFR associated with Port 2 8-bit register where each bit is associated with a specific pin of Port 2 (C8051 manual pg 175) Special Function Registers, Ports & Communication Using Port 2 as an example: The software communicates with the pins of Port 2 by using SFR P2 Input example: the current value (status of all 8 bits) can be used to give a variable, input, a value: input = P2; /* read PORT 2 */ Output example: the 8 pins of Port 2 can be assigned a value: P2 = 0x30; /* write to PORT 2*/ The hardware communicates by connecting wires to the pins of Port 2 8 9

More Examples of SFRs Application of SFRs Input/Output Port SFR P0 Configuration P1MDOUT output mode for P1 Control ADC1CN control of analog to digital converter Example: In the case of I/O ports, we need to input settings into some SFRs to determine how we will use the port. I/O Ports can be set to operate in different modes by switching transistors on and off 10 11 Configuration of Port 3 Output Mode The eight lines of Port 3 can be individually configured as push-pull (output) or open-drain (input). We set the configuration for each line through the special function register P3MDOUT Writing a 0 to a bit sets the corresponding pin of Port 3 to open drain; writing a 1 to a bit sets the corresponding pin of Port 3 to push-pull. Example: P3MDOUT = 0x0F; /* Pins 0-3 push-pull, pins 4-7 open-drain */ Configuring I/O Pins When using P0-P3 for digital output, set the bits in the corresponding output mode SFR for push-pull. Data can then be sent to the pins with the Port SFR When using P0-P3 for digital input, set the bits in the corresponding output mode SFR for open-drain. Additionally, you need to send a high value to those pins using the port SFR. Note: Port 1 can also be used for analog input, so additional settings need to be made in the P1MDIN SFR to set it for digital or analog input (C8051 manual pg 174). Since hardware configuration does not change in a typical application, these settings only need to be done once at the beginning of the code. (C8051 manual pg 176) 12 13

Configuring I/O Ports Here is an example using pins 2-7 of Port 2 and pins 0-2 of Port 3 for digital input (open-drain, set to 0) and pins 0-1 of Port 2 and 3-7 of Port 3 for digital output (push-pull, set to 1). Put these commands in a function that you will call at the beginning of the program 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 Port 2 config: 0x03 = 0000 0011 Port 3 config: 0xF8 = 1111 1000 Special Function Registers, Ports & Communication Each I/O port has a SFR associated with it Example: P2 is the SFR associated with Port 2 8-bit register where each bit is associated with a specific pin of Port 2 (C8051 manual pg 175) void Port_Init(void) { P2MDOUT = 0x03; // Pins 0-1 push-pull, pins 2-7 open-drain P2 = 0xFC; // Set pins 2-7 of P2 P3MDOUT = 0xF8; // Pins 3-7 push-pull, pins 0-2 open-drain P3 = 0x07; // Set pins 0-2 of P3 } 14 15 Bitwise operations, example { P2 = 0x19; // assignment operation P2 = 0xC1; // bitwise OR P2 &= ~0x33; // bitwise AND } P2 = 0x19 0 0 0 1 1 0 0 1 0xC1 = 1 1 0 0 0 0 0 1 P2 = 0xC1 1 1 0 1 1 0 0 1 0x33 = 0 0 1 1 0 0 1 1 ~0x33 = 1 1 0 0 1 1 0 0 P2 &= ~0x33 1 1 0 0 1 0 0 0 Sample Code, sbit Remember, we can use logic operations to change state of a pin, if P2.2 is connected to LED0 To turn on LED0, force P2.2 to go low P2 &= ~0x04; The C8051 also has the ability to change the state of individual bits on certain ports sbit at 0xA2 LED0; /* LED0 associated with P2.2 */ // the " " is 2 underscore characters together LED0 = 0; /* Light LED0 */ Same can be done with input ports to read state of individual pins 16 17

Reading & Writing to Bits & Ports Connections to the Microcontroller When should you use sbit? If you want to read or change the state of one or two individual bits of a port, using the sbit command can be very efficient. If you want to read or change the state of multiple pins, it is recommended that you use the port register. Example: To make bits 3-7 of Port 2 low: P2 = P2 & 0x07; or P2 &= 0x07; Each protoboard has an EVB Port Connector, see back cover of lab manual and pin sheet For example, hardware connects to Port 3 by using pins 31-38. Review the numbering scheme on the protoboard connector block to EVB. Note the location of pins 1 and 2 to see how they are sequenced. 18 19 Pin-out Form available on LMS Lab Check-Off Before implementing code and setting up the hardware, determine the initialization and EVB pin connections. Example: complete the pin-out form using the following information P2.6 is a pushbutton input with an sbit label PB1 P2.7 is a slide switch input with an sbit label SS P3.2 is an LED output with an sbit label LED0 Indicate Port pins used, sbit labels and Port initialization code When you complete a lab assignment, you will need to demonstrate your lab to a TA NOTE: We NO LONGER require it to be a TA from your section! Check-off procedure All partners should be present (but missing member will lose points) Neatness of the wiring matters Lab Notebook needs to be completed to that point You will be asked questions from the Demonstration and Verification section at end of lab as well as some additional questions All partners need to know lab well Questions will be directed towards each partner If the laboratory does not completely meet the requirements: You will need to correct the problem Request a new check-off and there may be a small penalty 20 21

IMPORTANT: Compiler Issues Lab 1, part 1 Pseudo Code Remember Do not use special characters in the file name - and _ are OK, but NOT # Only use a single. in the name Save your program as a.c file (.c files are actually just plain text files) compiler directives declare global variables function prototypes main function declare local variables initialization functions while (TRUE) read sensors set outputs for LED, buzzer and BILED end while end main function 22 23 Pseudo Code continued Pseudo Code in general function initialize ports() set ports 2 and 3 for input/output Alternative approach (not recommended): can create individual functions for each input bit, but using sbits directly is much simpler function sensor_1() read push button 1 and return appropriate value function sensor_2() read push button 2 and return appropriate value function sensor_3() read slide switch and return appropriate value function set outputs() determine LED, buzzer and BILED states based on the four conditions In general, there is no single best code implementation The pseudo-code should reflect your approach to solving the specified problem 24 25

Continue Lab 1, part 1 Complete Pin-out form for Lab 1, part 1 Include it in your notebook If you finish and need to get checked off See Demonstration and Verification at end of Lab 1, part 1 description. At a minimum, start Homework 4 (see due date on course calendar) By this point, you can use open shop hours to complete the lab and get checked off All partners should be present for check-off. Quiz 1 next Class RPILMS BRING YOUR LAPTOP 40 Minutes; open printed book and notes NO old quiz copies, NO other web pages except LMS Calculators OK, but NOT on cellphones Coverage Logic review Worksheet #2 Pseudo Code Indent for loops Must logically work Number conversion review Worksheet #1 Wiring see example problem 26 27 Next Class Quiz #1 (see sample problem on wiring) Homework #4 due Lab 1, part 1 check-off Before you leave Turn off the power to the car. Return your protoboard to cabinet slot that matches number on protoboard. Parts bags should be left with protoboard. Return your logic probe to the back cabinet. 28