ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #20: Using SPI The DAC

Similar documents
ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049-E17 Lecture 6 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

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

Serial Peripheral Interface (SPI)

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #8: Making it work: LEDs, Buttons & Keypad

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

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT

ECE2049: Embedded Computing in Engineering Design A Term Fall 2017 Lecture #16: Interrupts and Event Driven Code

PIC Serial Peripheral Interface (SPI) to Digital Pot

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #15: More ADC Examples

Serial Peripheral Interface (SPI) Last updated 8/7/18

I also provide a purpose-built ADC/DAC board to support the lab experiment. This analogue I/O board in only needed for Part 3 and 4 of VERI.

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

Microcontrollers and Interfacing

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

Functional block diagram AD53x1 (Analog Devices)

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

Microcontrollers and Interfacing week 10 exercises

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #11: More Clocks and Timers

PSIM Tutorial. How to Use SPI in F2833x Target. February Powersim Inc.

AD5669R - Microcontroller No-OS Driver

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17, MSP430F5529 Launchpad User's Guide

PARALLEL COMMUNICATIONS

SPI bus communication with LDE/LME pressure sensors

ECE 471 Embedded Systems Lecture 20

An SPI interface for the 65(C)02 family of microprocessors

Serial Peripheral Interface (SPI)

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Serial communications with SPI

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT 1110 SINGLE, PARALLEL, IOUT, 16-BIT DAC

Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut

ASNTu2s PCB with Tiger Board USB to 7-Channel 3-Wire Interface Bridge Application Notes

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17

GRAPHICS LCD INTERFACING WITH 8051

SPI 3-Wire Master (VHDL)

Temperature Sensor TMP2 PMOD Part 1

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Marten van Dijk, Syed Kamran Haider

Pmod I2S2 Reference Manual

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller

Serial Peripheral Interface Bus SPI

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

SPI (Serial & Peripheral Interface)

Microcontroller basics

Serial Communication. Simplex Half-Duplex Duplex

Review Activity 1 CALL and RET commands in assembler

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

PIN ASSIGNMENT PIN DESCRIPTION

SPI Universal Serial Communication Interface SPI Mode

Topics. Interfacing chips

ECE2049 Homework #4 Analog-to-Digital Conversion and the ADC12 (Due Thursday 2/15/2018 to box outside AK-011 by 9 am)

< W3150A+ / W5100 Application Note for SPI >

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

These three counters can be programmed for either binary or BCD count.

CANopen IO X4 Fact sheet

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

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI. Laboratory Lesson 9: Serial Peripheral Interface (SPI)

The University of Texas at Arlington Lecture 21_Review

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

EECS 373 Midterm 2 Fall 2018

McMaster University Embedded Systems. Computer Engineering 4DS4 Lecture 6 Serial Peripherals Amin Vali Feb. 2016

EE251: Tuesday December 4

Getting Started with ESPI Interface Using the Z8 Encore! XP F1680

EECS 373 Design of Microprocessor-Based Systems

EEL 4924 Electrical Engineering Design (Senior Design) Team Baudiophile. Wireless Headphones

Lecture 25 March 23, 2012 Introduction to Serial Communications

Summer 2003 Lecture 21 07/15/03

Amarjeet Singh. January 30, 2012

SPI: Serial Peripheral Interface

EE445L Fall 2010 Final Version A Page 1 of 10

AN HI-3200 Avionics Data Management Engine Evaluation Board Software Guide

ECE Microcontrollers. Serial Peripheral Interface (SPI) & NRF24 Radio

UART TO SPI SPECIFICATION

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

EE251: Thursday November 30

Technical Documentation

Pmod modules are powered by the host via the interface s power and ground pins.

University Program Advance Material

Dallas Semiconductor DS1307 Real Time Clock. The DS 1307 is a real-time clock with 56 bytes of NV (nonvolatile)

CSCE 236 Embedded Systems, Spring 2012 Quiz/Test 2

Programming Sequences for the QF1Da512

TP80301 Data Sheet Copyright SIGMATONE Version 1.0

± 2g Tri-axis Accelerometer Specifications

CPE/EE 323 Introduction to Embedded Computer Systems Homework V

Interfacing Techniques in Embedded Systems

EE 456 Fall, Table 1 SPI bus signals. Figure 1 SPI Bus exchange of information between a master and a slave.

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory

DAC6e USER MANUAL V1.0

ECE251: Thursday November 8

MSP430 Interface to LMP91000 Code Library

DS1306. Serial Alarm Real Time Clock (RTC)

MSP430 Microcontroller Basics

PIC-I/O Multifunction I/O Controller

LAB4. Program the on chip SPI module

Transcription:

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #20: Using SPI The DAC Reading for Today: Users Guide Ch 35, MCP4921, data sheet, on-line articles Reading for Next Class: Users Guide 1.4, Davies 6.6-10 HW #5 (on web): Lab #4 (on web): Due Tuesday 2/27 (in class) Sign-off & code (on-line) submit Fri 3/2 (in class, 9 am) Exam #3 THURSDAY 3/1/2018 at 9 a.m. in AK-216 Last Class: >> Configuring USCI_B0 for SPI mode data format, clock selection, etc >> Implement CS and other required IO to the SPI device => digital I/O! >> Writing serial data to Sharp LCD Serial Peripheral Interface Bus (SPI) >> Used primarily for synchronous serial comms between a CPU and peripherals within the box = off-chip but on same PCB --> Synchronous = shared clock (supplied by master) = Transfer speeds ~Mbps MSP430 (master) SIMO SOMI SCLK some SPI device 1 (slave) some SPI device n (slave) GND CS 1 CS 1 CS n >> SPI usually (almost always) sends/receives data Most Significant Bit (MSB) first!! >> User must implement CS logic for each device Only 1 device and Master can use SPI bus at a time

Overview of MCP4921 SPI Digital-to-Analog Convert (DAC) >> Converts integer value (code) to a voltage >> MCP4921 is 12-bit DAC that outputs voltages rail-to-rail (0 to Vcc) >> To use SPI to run the DAC the programmer must... 1) Enable UCSI B0 for SPI mode 2) Select data format 3) Setup synchronous clock >> Wait. Isn't this what we did for the LCD screen? Can't we just use those SPI settings? YES! That is the whole behind SPI The DAC is connected to USCI B0 SCLK and data lines, exactly like LCD Since Sharp96x96_Init() is called at the beginning of configdisplay() which is called at the beginning of our demo project these is nothing more to do to setup USCI B0 registers SPI for the DAC Then programmer must... --> They are already set! 4) Select peripheral (CS) >> DAC actually uses 2 pins to enable serial data transfer -- first CS then LDAC CS => P8.2 LDAC => P3.7 Both of these are Active LOW

// From demo project peripherals.h /* * DAC pin assignment is as follows * LDAC P3.7 * CS P8.2 * MOSI/SDI P3.0 * SCLK P3.2 */ #define DAC_PORT_LDAC_SEL #define DAC_PORT_LDAC_DIR #define DAC_PORT_LDAC_OUT #define DAC_PORT_CS_SEL #define DAC_PORT_CS_DIR #define DAC_PORT_CS_OUT #define DAC_PIN_CS #define DAC_PIN_LDAC // etc... P3SEL P3DIR P3OUT P8OUT P8DIR P8OUT BIT2 BIT7 /** ********************************************** * Initialize the DAC and its associated SPI bus, * using parameters defined in peripherals.h ************************************************/ void DACInit(void) { // Configure LDAC and CS for digital IO outputs DAC_PORT_LDAC_SEL &= ~DAC_PIN_LDAC; DAC_PORT_LDAC_DIR = DAC_PIN_LDAC; DAC_PORT_LDAC_OUT = DAC_PIN_LDAC; // Deassert LDAC DAC_PORT_CS_SEL DAC_PORT_CS_DIR DAC_PORT_CS_OUT &= ~DAC_PIN_CS; = DAC_PIN_CS; = DAC_PIN_CS; // Deassert CS 5) Send or Receive data which? -- What do we want to send? --> then Poll to see if transfer complete

void DACSetValue(unsigned int dac_code) { // Start the SPI transmission by asserting CS (active low) // This assumes DACInit() already called DAC_PORT_CS_OUT &= ~DAC_PIN_CS; // Write in DAC configuration bits. From DAC data sheet // 3h=0011 to highest nibble. // 0=DACA, 0=buffered, 1=Gain=1, 1=Out Enbl dac_code = 0x3000; // Add control bits to DAC word uint8_t lo_byte = (unsigned char)(dac_code & 0x00FF); uint8_t hi_byte = (unsigned char)((dac_code & 0xFF00) >> 8); // First, send the high byte DAC_SPI_REG_TXBUF = hi_byte; // Wait for the SPI peripheral to finish transmitting while(!(dac_spi_reg_ifg & UCTXIFG)) { _no_operation(); // Then send the low byte DAC_SPI_REG_TXBUF = lo_byte; // Wait for the SPI peripheral to finish transmitting while(!(dac_spi_reg_ifg & UCTXIFG)) { _no_operation(); // We are done transmitting, so de-assert CS (set = 1) DAC_PORT_CS_OUT = DAC_PIN_CS; // This DAC is designed such that the code we send does not // take effect on the output until we toggle the LDAC pin. // This is because the DAC has multiple outputs. This design // enables a user to send voltage codes to each output and // have them all take effect at the same time. DAC_PORT_LDAC_OUT &= ~DAC_PIN_LDAC; // Assert LDAC delay_cycles(10); // small delay DAC_PORT_LDAC_OUT = DAC_PIN_LDAC; // De-assert LDAC

Now, how do we do useful stuff with the DAC? Ex: Create DC voltage 1.2 V assuming DAC V ref = 3.3V. Assuming DAC V ref = 5V. Ex: Create a 100 Hz square wave (0 to 1.2 V peak)

Ex: How would you create a saw-tooth wave?