UNIT 26 SPI Test 로봇 SW 교육원 조용수.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 6 Digital Inputs
Advertisements

LOGO Lab Supervisor – Dr. WH Lau EE3271 Design Laboratory.
Interrupt Controller Introduction to 8259.
MICROPROCESSORS TWO TYPES OF MODELS ARE USED :  PROGRAMMER’S MODEL :- THIS MODEL SHOWS FEATURES, SUCH AS INTERNAL REGISTERS, ADDRESS,DATA & CONTROL BUSES.
Programmable Interval Timer
Chung-Ta King National Tsing Hua University
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
SPI Serial Peripheral Interface. SPI Serial Peripheral Interface is communication between two devices, one bit at a time sequential one bit at time over.
UNIT 20 AD Converter Test 로봇 SW 교육원 조용수.
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that.
Serial Peripheral Interface (SPI)
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
NS Training Hardware. System Controller Module.
SPI By Alexander Maroudis. Outline What is SPI? SPI Configuration SPI Operation Master Slave Setup SPI Transactions SPI Digital Potentiometer Example.
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
UART Test UNIT 14 로봇 SW 교육원 조용수. 학습 목표 UART Init UART Send UART Receive UART -> Debugging Console Up/Down Game 제작 2.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
1 LHO 13 The 8051CF020 and the University Daughter Card.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
I2C Master Core Simulation Environment. I2C Master Core Requirements Coverage (*) Requirement I2C IP RS-906: The I2C IP shall define the period of time,
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Universal Asynchronous Receiver/Transmitter (UART)
ECE 371 – Unit 9 Interrupts (continued). Example Set up Two Interrupt Request Inputs: –Port H[0] Set Interrupt Flag on “0” to “1” transition (rising edge)
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
Real-time Systems Lab, Computer Science and Engineering, ASU Quark SPI Interface (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
SPI Test UNIT 26 로봇 SW 교육원 조용수. 학습 목표 SPI Sample SPI Read/Write Function SPI loop back Test MPL115A1 Pressure and Temperature Sensor 2.
7 - 1 Texas Instruments Incorporated Module 7 : Serial Peripheral Interface C28x 32-Bit-Digital Signal Controller TMS320F2812.
DsPIC30F4011 Fall DIP Switches  The upper four switches of SW1 are used to enable LEDs connected to PORTB/C, PORTA/D, PORTE and PORTF. For example,
PWM Test 2 UNIT 20 로봇 SW 교육원 조용수. 학습 목표 PWM Servo 제어 2.
UNIT 7 - INTRODUCTION TO I/O INTERFACING. TWO MAJOR TYPES OF I/O INTERFACING ISOLATED I/O - DEDICATED I/O INSTRUCTIONS ARE USED TO ACCESS I/O DEVICES.
Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
WIFI design Guide based PW620-I b/g ----Hardware section Orin.Zhu August 31 st, 2007.
Embedded Systems February 10, Serial Interface - SPI  Serial Peripheral Interface  Synchronous communications  Clock supplied by the Master.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Microprocessors A practical approach..
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
MICROCONTROLLER AND INTERFACING Presented by: Shefali Jethva ( ) Shivali Panchal ( ) Komal Soni ( ) Roll no. :- 14EC308.
PWM Test UNIT 20 로봇 SW 교육원 조용수. 학습 목표 PWM Init PWM LED 제어 2.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
 The LPC2xxx devices currently have two on- chip UARTS.  Except UART1 has additional modem support.
UNIT 24 I2C Test 로봇 SW 교육원 조용수.
Serial Peripheral Interface
Serial Communication Buses: I2C and SPI
Programming the I/O Hardware
Chapter 11: Inter-Integrated Circuit (I2C) Interface
8086 Microprocessor.
Interfacing of LCD with µP
Programmable Interval Timer
Chapter D – Serial Connections to the RPi and Analog-to-Digital Converters
Two Wire Interface (TWI)
Calculator in assembly language
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
Programming the I/O Hardware
Master I/O Connectors PL12 PL14 PL21 PL20 PL17.
8086 Registers Module M14.2 Sections 9.2, 10.1.
SPI Protocol and DAC Interfacing
Interrupts in C Programs
Example 13 The Serial Peripheral Interface (SPI)
Programmable Interval timer 8253 / 8254
SPI Protocol Sepehr Naimi
Programmable Interval timer 8253 / 8254
UNIT 24 I2C Test 로봇 SW 교육원 조용수.
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
ANALOG TO DIGITAL CONVERTER (ATD).
Prof. Chung-Ta King Department of Computer Science
Serial Peripheral Interface Bus
Presentation transcript:

UNIT 26 SPI Test 로봇 SW 교육원 조용수

학습 목표 SPI Sample SPI Read/Write Function SPI loop back Test MPL115A1 Pressure and Temperature Sensor

SPI Sample SPI Loop Back Source \M051_Series_BSP_CMSIS_Rev3.00.001\SampleCode\StdDriver\SPI_Loopback\KEIL

System Init void SYS_Init(void) { SYS_UnlockReg(); CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_HIRC, CLK_CLKDIV_UART(1)); CLK_SetModuleClock(SPI0_MODULE, CLK_CLKSEL1_SPI0_S_HCLK, MODULE_NoMsk); CLK_EnableModuleClock(UART0_MODULE); CLK_EnableModuleClock(SPI0_MODULE); SYS->P3_MFP = SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0; SYS->P1_MFP = SYS_MFP_P14_SPISS0 | SYS_MFP_P15_MOSI_0 | SYS_MFP_P16_MISO_0 | SYS_MFP_P17_SPICLK0; SYS_LockReg(); SystemCoreClockUpdate(); }

System Init void SPI_Init(void) { /* Configure as a master, clock idle low, 32-bit transaction, drive output on falling clock edge and latch input on rising edge. */ /* Set IP clock divider. SPI clock rate = 2MHz */ SPI_Open(SPI0, SPI_MASTER, SPI_MODE_0, 32, 2000000); /* Enable the automatic hardware slave select function. Select the SS pin and configure as low-active. */ SPI_EnableAutoSS(SPI0, SPI_SS, SPI_SS_ACTIVE_LOW); }

System Init while(1) { /* Write to TX register */ SPI_WRITE_TX0(SPI0, g_au32SourceData[u32DataCount]); /* Trigger SPI data transfer */ SPI_TRIGGER(SPI0); /* Check SPI0 bust status */ while(SPI_IS_BUSY(SPI0)); /* Read received data */ g_au32DestinationData[u32DataCount] = SPI_READ_RX0(SPI0); u32DataCount++; if(u32DataCount > TEST_COUNT) break; }

System Init while(1) { /* Write to TX register */ SPI_WRITE_TX0(SPI0, g_au32SourceData[u32DataCount]); /* Trigger SPI data transfer */ SPI_TRIGGER(SPI0); /* Check SPI0 bust status */ while(SPI_IS_BUSY(SPI0)); /* Read received data */ g_au32DestinationData[u32DataCount] = SPI_READ_RX0(SPI0); u32DataCount++; if(u32DataCount > TEST_COUNT) break; }

MPL115A1 Digitized pressure and temperature information together with programmed calibration coefficients for host micro use. Factory calibrated 50 kPa to 115 kPa absolute pressure ±1 kPa accuracy 2.375V to 5.5V supply Integrated ADC SPI Interface Monotonic pressure and temperature data outputs Surface mount RoHS compliant package

MPL115A1

MPL115A1

MPL115A1 SPI Command

System Init void SPI_Init(void) { /* Configure as a master, clock idle low, 32-bit transaction, drive output on falling clock edge and latch input on rising edge. */ /* Set IP clock divider. SPI clock rate = 2MHz */ SPI_Open(SPI0, SPI_MASTER, SPI_MODE_0, 8, 2000000); /* Enable the automatic hardware slave select function. Select the SS pin and configure as low-active. */ SPI_EnableAutoSS(SPI0, SPI_SS, SPI_SS_ACTIVE_LOW); }

MPL115A1 void writeSPI(char address , char data ) { int count = 1000; SPI_SET_SS_LOW(SPI0); while(count--); /* Write to TX register */ SPI_WRITE_TX0(SPI0, address); /* Trigger SPI data transfer */ SPI_TRIGGER(SPI0); /* Check SPI0 bust status */ while(SPI_IS_BUSY(SPI0)); SPI_WRITE_TX0(SPI0, data); SPI_SET_SS_HIGH(SPI0); }

MPL115A1 char readSPI(char address) { char read; int count = 1000; SPI_SET_SS_LOW(SPI0); while(count--); SPI_WRITE_TX0(SPI0, address); SPI_TRIGGER(SPI0); while(SPI_IS_BUSY(SPI0)); SPI_WRITE_TX0(SPI0, 0x00); read = SPI_READ_RX0(SPI0); SPI_SET_SS_HIGH(SPI0); return read; }

MPL115A1 #define NWS_BARO 30.04 #define PRESH 0x80 // 80 #define PRESL 0x82 // 82 #define TEMPH 0x84 // 84 #define TEMPL 0x86 // 86 #define A0MSB 0x88 // 88 #define A0LSB 0x8A // 8A #define B1MSB 0x8C // 8C #define B1LSB 0x8E // 8E #define B2MSB 0x90 // 90 #define B2LSB 0x92 // 92 #define C12MSB 0x94 // 94 #define C12LSB 0x96 // 96 #define C11MSB 0x98 // 98 #define C11LSB 0x9A // 9A #define C22MSB 0x9C // 9C #define C22LSB 0x9E // 9E

MPL115A1 float A0; float B1; float B2; float C12; void readMPL115A1_Coefficients() { int A0H, A0L, B1H, B1L, B2H, B2L, C12H, C12L; A0H = readSPI(A0MSB); A0L = readSPI(A0LSB); A0 = (A0H << 5) + (A0L >> 3) + (A0L & 0x07) / 8.0; B1H = readSPI(B1MSB); B1L = readSPI(B1LSB); B1 = ((((B1H & 0x1F ) * 0x100) + B1L) / 8192.0) - 3; B2H = readSPI(B2MSB); B2L = readSPI(B2LSB); B2 = ((((B2H - 0x80 ) << 8) + B2L) / 16384.0) - 2; C12H = readSPI(C12MSB); C12L = readSPI(C12LSB); C12 = (((C12H * 0x100 ) + C12L) / 16777216.0) ; }

MPL115A1 float readMPL115A1() { int count = 30000; unsigned char uiPH, uiPL; float press = 0.0; float pressure = 0.0; float presKPa = 0.0; float temp = 0.0; unsigned int uiTadc; unsigned char uiTH, uiTL; unsigned int temperature_counts = 0; writeSPI(0x24, 0x00); // Start temperature conversion while(count--); // Read pressure uiTH = readSPI(TEMPH); uiTL = readSPI(TEMPL); uiPH = readSPI(PRESH); uiPL = readSPI(PRESL); printf("Read MPL115A1 0x%x, 0x%x \n", uiTH, uiTL); printf("Read MPL115A1 0x%x, 0x%x \n", uiPH, uiPL); uiTadc = (unsigned int) uiTH << 8; uiTadc += (unsigned int) uiTL & 0x00FF; // Temperature is a 10bit value uiTadc = uiTadc >> 6; // -5.35 counts per °C, 472 counts is 25°C temp = 25 + (uiTadc - 472) / -5.35; printf("Temperature %f \n", temp); press = ((uiPH * 256 ) + uiPL) / 64; temp = ((uiTH * 256) + uiTH) / 64; pressure = A0 + (B1 + C12 * temp) * press + B2 * temp; presKPa = pressure * (65.0/1023.0) + 50.0; printf("Pressure %f , Pressure(KPa) %f \n", pressure, presKPa); }

MPL115A1 uiTadc = (unsigned int) uiTH << 8; uiTadc += (unsigned int) uiTL & 0x00FF; // Temperature is a 10bit value uiTadc = uiTadc >> 6; // -5.35 counts per °C, 472 counts is 25°C temp = 25 + (uiTadc - 472) / -5.35; printf("Temperature %f \n", temp); press = ((uiPH * 256 ) + uiPL) / 64; temp = ((uiTH * 256) + uiTH) / 64; pressure = A0 + (B1 + C12 * temp) * press + B2 * temp; presKPa = pressure * (65.0/1023.0) + 50.0; printf("Pressure %f , Pressure(KPa) %f \n", pressure, presKPa); }