ECE 382 Lesson 14 Lesson Outline Polling Multiplexing

Slides:



Advertisements
Similar presentations
MSP430 Assembly Paul Roper
Advertisements

ECE 447 Fall 2009 Lecture 2: TI MSP430 Software Development C and MSP430 Assembly.
ECE 382 Lesson 14 Lesson Outline Polling Multiplexing Intro to Logic Analyzer Debouncing Software Delay Routines Admin Assignment 3b due BOC today Assignment.
1 Chapter 3 Jump, Loop, and Call Instructions. 2 Sections 3.1 Loop and Jump Instructions 3.2 Call Instructions 3.3 Time Delay Generation and Calculation.
University of Tehran 1 Microprocessor System Design Interrupt Omid Fatemi
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
A look at interrupts What are interrupts and why are they needed.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
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.
Chapter 5 – MSP430 ISA The Instruction Set
Chung-Ta King National Tsing Hua University
ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2.
6.828: PC hardware and x86 Frans Kaashoek
Renesas Electronics Europe GmbH A © 2010 Renesas Electronics Corporation. All rights reserved. RL78 Clock Generator.
Chapter 8 – Stacks
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
MICROPROCESSOR INPUT/OUTPUT
Ultra-low Power Motion Detection using the MSP430F2013.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This course provides an overview of the CPU architecture.
Lecturers: Professor John Devlin Mr Robert Ross
UBI >> Contents Lecture 3 MSP430 Assembly Language Instructions MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT)
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Lecture 16: Digital to Analog Converter - PWM Implementation
IO Subsystem IV Ports and peripherals. IO Subsystem (1) All devices connected to the system buses, other than memory and CPU – Input and output ports.
Computer Systems - Processor. Objectives To investigate and understand the structure and role of the processor.
TI MSP430 MICROCONTROLLERS BY ADITYA PATHAK. THE MSP FAMILY Ultra-low power; mixed signal processors Widely used in battery operated applications Uses.
The Intel 8086 Processor Josh Broome Dave Overstrom Jonathan Kagarise Christopher Lindsay.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
ECE 382 Lesson 32 Lesson Outline Lab 6 Introduction Pulse Width Modulation Capture / Compare Example Lab 6 Tips Admin Lab#6 “prelab” due BOC lesson 33.
ECE 3430 – Intro to Microcomputer Systems
Seminar On 8085 microprocessor
CS4101 嵌入式系統概論 General Purpose IO
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
ECE 382 Lesson 22 Readings Lesson Outline Writing Clean Code
ECE 382 Lesson 15 Lesson Outline S/W Delays Wrap up
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Lecture 8: TI MSP430 Interrupts, ISRs
80C51 Block Diagram ECE Overview.
ECE 3430 – Intro to Microcomputer Systems
Lesson Outline Interrupts Admin Assignment #9 due next lesson
Code review: GPIO, timer, and ISR
ECE 382 Lesson 3 ECE 382Website:
ECE 382 Lesson 6 Lesson Outline Status Register Flow of Control
S04: MSP430 Microarchitecture
Chapter 6 General Purpose Input/Output
ECE 382 Lesson 7 Lesson Outline Miniquiz Instruction Execution Time
Lesson Outline Peripherals Memory-Mapped IO Ports GPIO Multiplexing
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Quiz 4.1 Four LEDs are attached to Port 4, bits 0 thru 3. Indicate which LEDs are ON/OFF after each instruction is executed. P4.7 P4.6 P4.5 P4.4 P4.3.
ECE 382 Lesson 4 Lesson Outline Readings
Blinking an LED Using MSP430ware to Control GPIO
Interrupts, Tasks and Timers
AT91 Memory Interface This training module describes the External Bus Interface (EBI), which generatesthe signals that control the access to the external.
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
L13b – 32 bit multiply Department of Electrical and
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Wireless Embedded Systems
MSP430 Clock System and Timer
Computer Operation 6/22/2019.
Presentation transcript:

ECE 382 Lesson 14 Lesson Outline Polling Multiplexing Intro to Logic Analyzer Debouncing Software Delay Routines Admin Extra Credit badlec5.asm due today

Multiplexing Reference: Page 43 of Device Specific (BB pp 124) Only 20 Pins !!! But want access to many more signals Therefore, each pin shares several signals  multiplexing Use PxSEL1 and PxSEL2 to select signal for each pin The details are in the MSP430G2x53 2x13 Mixed Signal MCU Datasheet. Reference: Page 43 of Device Specific (BB pp 124) And/Or Page 333 of Family User Guide (BB pp 41)

Pitfall !!! Reference: Page 43 of Device Specific Let's say I wanted to make the UCA0SOMI function available on P1.1: ; 'from USCI' means this bit is set automatically by the USCI when enabled bis.b #BIT1, P1SEL bis.b #BIT1, P1SEL2 Reference: Page 43 of Device Specific

Pitfall !!! Anything wrong with this? What do these commands do? mov.b #0xff, P1DIR What do these commands do? mov.b #0b00001111, &P1DIR bis.b #0b00001111, &P1OUT mov.b #0xff, &P1OUT mov.b &P1IN, r5

Interfacing Peripherals to the MCU What is Polling? What are Interrupts? bic.b #BIT3, &P1DIR bis.b #BIT3, &P1REN bis.b #BIT3, &P1OUT poll_button: bit.b #BIT3, &P1IN jnz poll_button ; Do useful stuff after button press forever jmp forever

Logic Analyzer What is the difference between an O’Scope and a Logic Analyzer? Debouncing?

Logic Analyzer Debouncing: random bounces each time…

Is bouncing a problem? bis.b #BIT3, &P1OUT bis.b #BIT3, &P1REN bic.b #BIT3, &P1DIR clr r4 check_btn: bit.b #BIT3, &P1IN jz btn_pushed jmp check_btn btn_pushed: inc r4 wait: bit.b #BIT3, &P1IN jz wait inc r4

Debouncing Strategies How can we fix this?

Debouncing Strategies How can we fix this? There is hardware debouncing And there is software debouncing: Delay until bouncing has stopped with a Software Delay Routine or with a Hardware Counter Then resume What are some potential problems with this?

Debouncing Strategies How can we fix this? There is hardware debouncing And there is software debouncing: Delay until bouncing has stopped with a Software Delay Routine or with a Hardware Counter Then resume What are some potential problems with this? You could delay for too short a period and still be impacted by bouncing. You could delay for too long a period and miss good button pushes

Example Software Delay Routine How long is this software delay? call #software_delay software_delay: push r5 mov.w #0xaaaa, r5 delay: dec r5 jnz delay pop r5 ret MSP430 Family Users Guide Section 3.4.4, p 60 for cycles per instruction (Blue Book pp 18) For emulated instructions, use the table on the back of your blue book as a guide. See Sections 3.4.5 – 3.4.6 of the Family users guide for more information.

Emulated Instructions Assembly Instruction Notes NOP MOV r3, r3 Any register from r3 to r15 would do the same thing. POP dst MOV @SP+, dst BR dst MOV dst, PC RET MOV @SP+, PC CLRC BIC #1, SR SETC BIS #1, SR CLRZ BIC #2, SR SETZ BIS #2, SR CLRN BIC #4, SR SETN BIS #4, SR DINT BIC #8, SR EINT BIS #8, SR

More Emulated Instructions Assembly Instruction RLA(.B) ADD(.B) dst, dst RLC(.B) ADDC(.B) dst, dst INV(.B) dst XOR(.B) #-1, dst CLR(.B) dst MOV(.B) #0, dst TST(.B) dst CMP(.B) #0, dst DEC(.B) dst SUB(.B) #1, dst DECD(.B) dst SUB(.B) #2, dst INC(.B) dst ADD(.B) #1, dst INCD(.B) dst ADD(.B) #2, dst ADC(.B) dst ADDC(.B) #0, dst DADC(.B) dst DADD(.B) #0, dst SBC(.B) dst SUBC(.B) #0, dst :

Example Software Delay Routine How long is this software delay? call #software_delay ; 5 cycles software_delay: push r5 ; 3 cycles mov.w #0xaaaa, r5 ; 2 cycles delay: dec r5 ; 2 cycles? ; no 1 cycle !!! jnz delay ; 2 cycles pop r5 ; 2 cycles ret ; 2 cycles? ; no 3 cycles !!! 5 + 3 + 2 + (0xaaaa * (1 + 2)) + 2 + 3 = 131085 total clock cycles Only variable is r5… if I change r5 by “one”, how many cycles is this? (ie., precision of delay?) So, How long in time is this?

MSP430’s Digitally Controlled Oscillator MSP430’s Clock = Digitally Controlled Oscillator (DCO) Advantage: It is tunable. Can run at many different frequencies Disadvantage: It is an RC oscillator, so can be inaccurate Default: 1 MHz, with significant variance (0.8MHz - 1.5MHz) Fix: At the factory, each chip is calibrating with a more accurate quartz crystal resonator. TI stores the proper calibrated values for DCOCTL and BCSCTL1 for 1MHz, 8MHz, 12MHz, and 16MHz in protected memory. We can measure clock speed (SMCLK) on P1.4

SMCLK BB Pg. 126 bis.b #BIT4, &P1DIR bis.b #BIT4, &P1SEL forever jmp forever If Clock period is 912ns, how long is 131085 clock cycles? BB Pg. 126

Measure Software Delay Routine bis.b #BIT0, &P1DIR blinkLED: bic.b #BIT0, &P1OUT call #software_delay bis.b #BIT0, &P1OUT jmp blinkLED software_delay: push r5 mov.w #0xaaaa, r5 delay: dec r5 jnz delay pop r5 ret

Measure SW delay routine bis.b #BIT4, &P1DIR bis.b #BIT4, &P1SEL forever jmp forever If Clock period is 912ns, how long is 131085 clock cycles?

Debounced code with SW delay ; Setup P1.3 for button input bis.b #BIT3, &P1OUT bis.b #BIT3, &P1REN bic.b #BIT3, &P1DIR clr R4 ; BtnCounter ; Increment Btn Counter on Btn press ; A delay is used immediately after the press and release check_btn: bit.b #BIT3, &P1IN jnz check_btn inc R4 call #software_delay jmp btn_pushed btn_pushed: bit.b #BIT3, &P1IN jz btn_pushed ; Btn released jmp check_btn

Debounced code with SW delay ; ------------------------------------------- ; Software delay ; Purpose: Delays code based on value of R5 ; R5 is currently hard coded as 0xAAAA software_delay: push r5 mov.w #0xaaaa, r5 delay: dec r5 jnz delay pop r5 ret ; End Software delay ---------------------------