CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO

Slides:



Advertisements
Similar presentations
Lab 1 I/O, timers, interrupts on the eZ430-RF2500 Thomas Watteyne EE290Q – Spring 2010
Advertisements

Outline MSP430 LaunchPad MSP430 Microcontroller
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
LAB 6: Serial Communication
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise.
ECE 382 Lesson 2 Readings Lesson Outline Admin Assembler Linker
ECE Lecture 1 1 L15 – Digital I/O Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
KEG-012 A.K.A. EMMA AND DAVE’S GROUPS Design Projects.
MSP430 Intro. Why embedded systems? Big bang-for-the-buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more.
CS4101 嵌入式系統概論 Software UART Revisited Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430.
Chung-Ta King National Tsing Hua University
LAB 7: WDT+ and Low-Power Optimization
Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.
BYU CS 124Lab 0 - Warm-up Lab1 Lab 0 – Warm-up Lab 1.Acquire a Texas Instruments MSP430 LaunchPad Development Tool. 2.Setup a CS user account. 3.Install.
Lecture 11: TI MSP430 Timers Compare Modes
LAB 8: Program Design Pattern and Software Architecture
Ultra-low Power Motion Detection using the MSP430F2013.
ECS642U Embedded Systems Digital I/O William Marsh.
Lecturers: Professor John Devlin Mr Robert Ross
Good LED Circuit 5V0 GND. What Voltage Does Meter See? Answer: 5 V.
ECE Lecture 1 1 L15 –I/O Part II Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
1-3 GPIO_Output(LuminaryLibrary) 1.Alter the output current to 4mA 2.Let LED0 turn on but LED 1 turn off. Modify your program in E:\yourname\arm.
Introduction to the DE0 Board Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Computer Logic Design.
Embedded Systems Lecture 4 January 20, 2016.
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
UNIT 2. CPUXV2 20-bit addressing User-definable Boot Strap Loader RAM starts at 0x1C00 Beginning of MAIN flash moves according to RAM Vector table starts.
National Tsing Hua University CS4101 嵌入式系統概論 Introduction to LaunchPad Prof. Chung-Ta King Department of Computer Science National Tsing Hua University,
Introduction In this lab , we will learn
Outline Introduction to NuMaker TRIO Programming environment setup
Lab 7 Basic 1: Game of Memory
Introduction In this lab , we will learn
Outline Introduction to digital-to-analog converter (DAC)
Introduction Why low power?
Introduction Why low power?
CS4101 嵌入式系統概論 General Purpose IO
Lecture 8: TI MSP430 Interrupts, ISRs
CS4101 嵌入式系統概論 Introduction to LaunchPad
Microcontroller basics
CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Lesson Outline Interrupts Admin Assignment #9 due next lesson
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
CS4101 Introduction to Embedded Systems Lab 1: MSP430 LaunchPad IDE
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Chapter 6 General Purpose Input/Output
Lesson Outline Peripherals Memory-Mapped IO Ports GPIO Multiplexing
Prof. Chung-Ta King Department of Computer Science
COMP211 Computer Logic Design Introduction to the DE2 Board
CS4101 嵌入式系統概論 General Purpose IO
Arduino.
Blinking an LED Using MSP430ware to Control GPIO
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
CS4101 Introduction to Embedded Systems Lab 7: Serial Communication
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno
CS4101 Introduction to Embedded Systems Lab 7: Serial Communication
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
ECE 3567 Microcontroller Lab
Lab 1. Introduction to the DE2 Board
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Lecture 4. Introduction to the DE2 Board
Prof. Chung-Ta King Department of Computer Science
MSP430 Clock System and Timer
ECE 3567 Microcontrollers Lab
A modular robot for use in the RoboSumo lab
Presentation transcript:

CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan

Introduction In this lab, we will learn the basic GPIO of MSP430 LaunchPad Configure the I/O port of LaunchPad for input and output Run the debugger for basic debugging

Sample Code 1 for Input #include <msp430.h> #define LED1 BIT0 //P1.0 to red LED #define B1 BIT3 //P1.3 to button void main(void){ WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer P1OUT |= LED1 + B1; P1DIR = LED1; //Set pin with LED1 to output P1REN = B1; //Set pin to use pull-up resistor for(;;){ //Loop forever if((P1IN & B1) ==0){ //Is button down? P1OUT &= ~LED1; // Yes, turn LED1 off } else{ P1OUT |= LED1; // No, turn LED1 on } } Whenever button is down, turn LED off. Whenever button is up, turn LED on. P1OUT is not initialized and must be written before configuring the pin for output. Assume button is active low (0  pressed; 1  depressed)

Sample Code 2 for Debugger #include <msp430.h> #define LED1 BIT6 // P1.0 to green LED #define B1 BIT3 // P1.3 to button volatile unsigned int i, j; void main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1OUT |= LED1 + B1; P1DIR = LED1; // Set pin with LED1 to output P1REN = B1; // Set pin to use pull-up resistor for(;;){ while((P1IN & B1) != 0){ // Loop on button up i = P1IN; j = P1OUT; } P1OUT &= ~LED1; // Turn LED1 off while((P1IN & B1) == 0){ // Loop on button down P1OUT |= LED1; // Turn LED1 on } On button down, turn LED off. On button up, turn LED on.

How to Debug? In the code line containing: i = P1IN; j = P1OUT; Add new expression from Expressions window Right-click on the appropriate line of code and set the Breakpoint When the code runs, it will hit the breakpoint and stop You can now observe the value

Debugger Output 1111 1110 01001000 00000110 00001000 No need to care about other bits!

Lab 1 Basic 1: Flash the red and green LED alternatively whenever the button is pressed and released once. The LEDs change right after the button is released. Run the debugger to show the content of P1IN whenever the LEDs change. Basic 2: When the button is down, only flash the green LED. But if the button is pressed “long” enough, flash only the red LED instead. When the button is released, neither of the LEDs is on.