PIC Serial Peripheral Interface (SPI) to Digital Pot

Similar documents
11.4 THE SERIAL PERIPHERAL INTERFACE (SPI)

< W3150A+ / W5100 Application Note for SPI >

Amarjeet Singh. January 30, 2012

SPI (Serial & Peripheral Interface)

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Microcontrollers and Interfacing

PmodJSTK2 Reference Manual. Overview. 1 Functional Descriptions. Revised July 19, 2016 This manual applies to the PmodJSTK2 rev. C

Voltage Regulator Board User Guide

MICROCONTROLLER S PROGRAMMER

DIGI POT 3 click. PID: MIKROE 3016 Weight: 25 g

Microcontrollers and Interfacing week 10 exercises

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.

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

Serial Peripheral Interface (SPI)

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

DEVBOARD3 DATASHEET. 10Mbits Ethernet & SD card Development Board PIC18F67J60 MICROCHIP

Interfacing to Digital Potentiometers

C8051F700 Serial Peripheral Interface (SPI) Overview

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

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

PICado Alpha Development Board V1.0

PIC Dev 14 Through hole PCB Assembly and Test Lab 1

PIC Dev 14 Surface Mount PCB Assembly and Test Lab 1

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

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

eip-10 Embedded TCP/IP 10-BaseT Network Module Features Description Applications

LIN bus board datasheet EB

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

An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus

ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ. Embedded System Design

Exercise 4-1. DSP Peripherals EXERCISE OBJECTIVES

General-Purpose Microcontroller Module 12a Hardware Reference Release 1.4a (October 11, 2017)

Lab 16: Tri-State Busses and Memory U.C. Davis Physics 116B Note: We may use a more modern RAM chip. Pinouts, etc. will be provided.

Lecture 14 Serial Peripheral Interface

PIXI click PID: MIKROE Weight: 28 g

Understanding SPI with Precision Data Converters

Serial Peripheral Interface (SPI) Host Controller Data Sheet

HZX N03 Bluetooth 4.0 Low Energy Module Datasheet

Section 16. Basic Sychronous Serial Port (BSSP)

BroadR-Reach click PID: MIKROE Weight: 26 g

The 9S12 Serial Peripheral Inteface (SPI) Huang Section 10.2 through 10.6 SPI Block User Guide

Design and Verification of Serial Peripheral Interface 1 Ananthula Srinivas, 2 M.Kiran Kumar, 3 Jugal Kishore Bhandari

I2C TM Master Library Module (Polled)

I2C and SPI Foundation

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

Section 5 SERCOM. Tasks SPI. In this section you will learn:

Interfacing Techniques in Embedded Systems

LAB4. Program the on chip SPI module

COOKING WITH TEAM 279

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

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

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

Serial Peripheral Interface Bus SPI

MX Educational Target User Manual

The Serial Peripheral Interface

Universität Dortmund. IO and Peripheral Interfaces

From Datasheets to Digital Logic. synthesizing an FPGA SPI slave from the gates

Real Time Embedded Systems. Lecture 1 January 17, 2012

AT89S4D12. 8-Bit Microcontroller with 132K Bytes Flash Data Memory AT89S4D12. Features. Description. Pin Configurations

Breeze Board. Type A. User Manual.

Environmental Data Acquisition Using (ENC28J60)

Wireless communication for social robotics. Gu C. Department of Electrical & Computer Enginnering. National University of.

DataFlash. Application Note. Using Atmel s DataFlash. Introduction (AN-4)

ECE 471 Embedded Systems Lecture 20

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

Arduino Uno R3 INTRODUCTION

Anadigm FPAA Solutions Training Class III

PIC-I/O Multifunction I/O Controller

chipkit WiFire Board Reference Manual May 12, 2014

Modtronix Engineering Modular Electronic Solutions SBC28DC. Single board computer for 28 pin DIP PICs

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

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

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

PIC18F452 Oven Calibrator Using the MAX6674/MAX6675 Thermocouple-to-Digital Converter. Group: SMOKE Duston Cline Adam McCorkle

Card Reader Board EB037-00

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

Block Diagram. mast_sel. mast_inst. mast_data. mast_val mast_rdy. clk. slv_sel. slv_inst. slv_data. slv_val slv_rdy. rfifo_depth_log2.

ARDUINO MICRO WITHOUT HEADERS Code: A000093

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING. BEng(Hons) Electrical and Electronics Engineering SEMESTER 1 EXAMINATION 2016/2017

ET-PIC 24 WEB-V1. o Central Processing Unit (CPU) o System. o nanowatt Power Managed Modes. o Analog Features

Arduino Dock 2. The Hardware

Breeze Board. Type B. User Manual.

PCB-STM32-F3U. Development baseboard for the STMicro Discovery-F3 module (STMicro part# STM32F3DISCOVERY)

output current sink/source 2 ma PIC 16F690 (see datasheet) SPI resolution 12 bit position accuracy 0.2 deg

ISA Host Controller 15a Hardware Reference Release 1.2 (October 16, 2017)

Logic Chip Tester User Manual SW Version /8/2012. Chapter 1 Introduction/Background

SPI bus communication with LDE/LME pressure sensors

Growing Together Globally Serial Communication Design In Embedded System

Part 1 Using Serial EEPROMs

Mayhew Labs. Extended ADC Shield User Manual

SPI Overview and Operation

Serial Buses in Industrial and Automotive Applications

Serial Communication

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface

SimPLC. User Manual.

DS1305EN. Serial Alarm Real-Time Clock

Pmod I2S2 Reference Manual

DS1306. Serial Alarm Real Time Clock (RTC)

SPI Memory and D/A board datasheet EB

Transcription:

Name Lab Section PIC Serial Peripheral Interface (SPI) to Digital Pot Lab 7 Introduction: SPI is a popular synchronous serial communication protocol that allows ICs to communicate over short distances (PCB level communication). In this lab you will use the Serial Peripheral Interface (SPI) to communicate with a digital potentiometer. Lab Requirements: 1. Demonstration of a digital potentiometer as a programmable attenuator. 2. Submission of your neatly formatted source code. Demo Check (JK) About the Serial Peripheral Interface: SPI is a full-duplex synchronous serial communication protocol for data transfer between integrated circuits on a PCB. The protocol uses a master/ slave relationship where the master initiates all data transfers and generates the data synchronization clock. The standard bus connections are a Serial Clock (SCK), Master-Out-Slave-In (MOSI), Master-In-Slave-Out (MISO) and an active low Slave Select (nss). Each slave device has its own Slave Select (nss) signal which dictates when the device is participating in bus transfers. A typical SPI connection diagram is shown below: Figure 1 - SPI Connection Diagram

The SPI protocol operates as a shift register where data is transferred from the master to the slave and from the slave to the master at the same time. The data is shifted one bit at a time on the SCK edge. Unfortunately, there is no standardization on the clock edge for data shift or on the clock polarity so four different modes are possible. When connecting to a new peripheral it is important to study the waveform timing diagram to determine the clock polarity and phase. Figure 2 - SPI Shift Register Before a data transfer begins the master must assert the nss signal by driving it low. Then the data will be exchanged one bit at a time between the master and the slave. The Data Transfer diagram below illustrates a Mode 3 transfer where the SCK idles high and data is valid on the rising edge of the SCK. At the end of the data transfer the nss signal is brought high to deselect the peripheral. Figure 3 - SPI Data Transfer

Most modern microcontrollers contain dedicated hardware to implement a master or slave peripheral interface. In the PIC family of microcontrollers this functionality is located in the Master Synchronous Serial Port (MSSP) Module. The MSSP is capable of being configured to implement either the SPI or I2C bus protocol. The hardware can be configured to operate as either a master or as a slave device. Today we will be setting up the MSSP for SPI Master Mode operation. Figure 4 - MSSP SPI Block Diagram

SSP1CON1 = 0b00110010; To exchange data between the master and slave simply load the SSP data buffer then block until the transfer is finished. The code below also clears collision flag just in case it was set by a poorly timed write to the buffer. Don t forget assert the nss line before calling the SPI_SHIFT_8 function. uint8_t SPI_SHIFT_8 (uint8_t data) { SSP1CON1bits.WCOL = 0; SSP1BUF = data; while (SSP1STATbits.BF == 0){} return (SSP1BUF); } // Clear Write Collision flag just in Case // Load Buffer with Data to Shift // Block until 8b transferred // Return Data/Dummy

Digital Potentiometer: Digital potentiometers can be useful in circuits where you need to control an analog function with a microcontroller. For this lab you will be interfacing the PIC16F18324 to a MCP4151-503 (50k) Potentiometer using the SPI Interface. The MCP4151 is available in an 8-pin DIP package which forces an unusual SPI interface due to the low pin count. Figure 5 - MCP4151 Pinout The MCP4151 uses a shared bi-directional SDI/SDO line in order to fit both pins on the small package. R1 must be sized to not limit the SDO voltage below the logic threshold of the SDI of the MCP4151. Since there is not much value in reading the registers of the digital pot we will simplify our design by not using the MISO (SDI) connection. Figure 6 MCP4151 Bi-Directional Hardware Configuration If we only care about setting the digital potentiometers wiper position we can simplify the connection as shown in figure 7 below. If we us this simplified method to interconnect the parts we must be careful to only issue write commands from the master. Figure 7 - Simplified Connection Diagram

Data packets can be either 8 or 16 bits in length depending on the function. The general memory map for Microchip digital potentiometers is show in Figure 9 below. For the MCP4151 we will only be writing to address 00h which will set the wiper position of the potentiometer. The pot has 257 steps so the range of values to be written to the data transfer payload is 0 to 256. A convenient way to create an input that represents the desired wiper position is to use the analog to digital converter connected to the trim pot on your board. The 10b ADC value will need to be scaled and manipulated in order to create the 8b +1 range of the digital pot. Figure 8 - MCP4151 Commands Figure 9 - MCP4151 Memory Map

Digital Potentiometer Interfacing: Unlike a traditional passive potentiometer, the digital potentiometer can only work with signals that fall within the power rails of the chip. Signals outside of the power rails (0 to 5V for this lab) can permanently damage the component and must be avoided. To build the programmable attenuator you will configure the digital pot as a voltage divider by feeding the signal to be attenuated into the P0A pin and grounding the P0B pin. The output will be taken from the wiper at P0W. You will use a signal generator to create a 1kHz Sine wave with a 5Vpp amplitude and 2.5V of DC offset. Verify the signal amplitude and offset using the oscilloscope before connecting it to the digital pot.

Schematic: Neatly draw the schematic of your circuit in the box below. Be sure to include component values, pin numbers, supply voltages and support circuitry. You do not need to include unused header connections or the microcontroller s ICSP interface.