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

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

or between microcontrollers)

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

Interfacing Techniques in Embedded Systems

Application note, Nordic nrf24l01 with Bascom-Avr

User Manual of NRF24L01 Breakout Board

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

Tutorial 0: Everything You Need to Know about the nrf24l01 and MiRF-v2

PARALLEL COMMUNICATIONS

Serial Peripheral Interface Bus SPI

Universität Dortmund. IO and Peripheral Interfaces

Amarjeet Singh. January 30, 2012

Serial Communication. Simplex Half-Duplex Duplex

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

ArduCAM-M-2MP Camera Shield

SPI (Serial & Peripheral Interface)

CHECKPOINT 3 Wireless Transceiver

PL1167. Low Power High Performance Single Chip 2.4GHz Transceiver. Product Description: Key Features: Applications: Pin Configuration:

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

Digital Input and Output

RFIC TX/RX Configuration

< W3150A+ / W5100 Application Note for SPI >

Introduction to I2C & SPI. Chapter 22

HZX N03 Bluetooth 4.0 Low Energy Module Datasheet

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

CAN protocol enhancement

VORAGO VA108x0 I 2 C programming application note

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

Project Overview. Chipcon Transceiver. Transceiver Overview (1) Transceiver Overview (2) EECS150 Spring 2006 Lab Lecture #8

Lecture 25 March 23, 2012 Introduction to Serial Communications

Basics of UART Communication

Raspberry Pi - I/O Interfaces

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

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

SPI Universal Serial Communication Interface SPI Mode

Concepts of Serial Communication

Inter-Integrated Circuit Bus IIC I2C TWI

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

Serial Communication. Simplex Half-Duplex Duplex

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

Growing Together Globally Serial Communication Design In Embedded System

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

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

OUTLINE. SPI Theory SPI Implementation STM32F0 SPI Resources System Overview Registers SPI Application Initialization Interface Examples

Microcontrollers and Interfacing

Serial Communications

ELET114A Bluetooth Module DATASHEET. Website: / 7

For reference only Refer to the latest documents for details

Serial Communication

Serial Buses in Industrial and Automotive Applications

INPUT-OUTPUT ORGANIZATION

18-349: Introduction to Embedded Real-Time Systems

Each I2C master has 8-deep transmit and receive FIFOs for efficient data handling. SPI to Dual I2C Masters. Registers

Understanding SPI with Precision Data Converters

PIC Serial Peripheral Interface (SPI) to Digital Pot

RL78 Serial interfaces

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

UART TO SPI SPECIFICATION

PIXI click PID: MIKROE Weight: 28 g

Serial Communication. Spring, 2018 Prof. Jungkeun Park

17. I 2 C communication channel

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

Operating Instructions Evaluation Board for dbc Operation with RS232 or SPI Interface

WM1030 Rev Introduction. Ultra low power DASH7 Modem. Applications. Description. 868 / 915 MHz. Features. WIZZILAB Technical datasheet 1/10

Unit 19 - Serial Communications 19.1

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -4 1 UNIT 4

SPI Framework Module Guide

Serial Communications

SH1030 Rev Introduction. Ultra low power DASH7 Arduino Shield Modem. Applications. Description. 868 MHz. Features

CHAPTER 5 REGISTER DESCRIPTIONS

BLE 1.4 SPI Driver Design Version 1.x (Draft)

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

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

SKB360I Bluetooth 4.0 Low Energy Module Datasheet

AN Multifunction Serial Interface of FM MCU. Contents. 1 Introduction

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

Serial Peripheral Interface (SPI)

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

4 Multiplexer. Y Fig Keyboard Scan Matrix

Dual Serial Shield User Manual

ECE 571 Advanced Microprocessor-Based Design Lecture 3

Serial Peripheral Interface (SPI)

AT88RF1354 SPI User Guide For CryptoRF

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

Color 7 click. PID: MIKROE 3062 Weight: 19 g

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

Microcontroller basics

How to create your own peripheral modules for use with the ARC EMSK and embarc

Pedometer 3 Click. PID: MIKROE 3259 Weight: 24 g

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

Section 16. Basic Sychronous Serial Port (BSSP)

Digital Circuits Part 2 - Communication

XEN1210 Magnetic Sensor

Nano RK And Zigduino. wnfa ta course hikaru4

C8051F700 Serial Peripheral Interface (SPI) Overview

MCS-51 Serial Port A T 8 9 C 5 2 1

Preliminary File System User Manual

Module Introduction. PURPOSE: The intent of this module, is to explain several of the important features of Freescale s i.mx1 applications processor.

ECE 471 Embedded Systems Lecture 20

Reindeer Technologies Pvt Ltd Excellence through Innovation

Transcription:

ECE 381 - Microcontrollers Serial Peripheral Interface (SPI) & NRF24 Radio

Lab 9 Summary We will develop a wireless temperature sensor Once a second, sample LM34CZ voltage Convert to floating point with 0.1 degree accuracy Send to BeagleBone Web Server at (146.163.133.81:8080) using NRF24 radio Wait 1s Repeat Also will be given a hex file to test NRF24 operation

Let s Break It Down Sample ADC Voltage from LM34CZ PSoC5 has built-in Delta-Sigma ADC (Also programmable amplifiers, filters, etc.) Also 2 hardware SAR ADCs Send Using NRF24 Radio NRF24 radio uses SPI to communicate SPI Protocol NRF24 configuration

LM34CZ 3 pins, (Vs = +5V, Vout Goes to pin on Port0[1]) NOTE: View on datasheet is from BOTTOM! Output 10mV / F This is what you sample Check DelSig datasheet for API functions ADC_Start() ADC_StartConverstion()...

Phwew! Onto SPI We now know about RS-232, and I2C SPI is another serial protocol for communicating between chips 4-Wire Bus MOSI (Master Out/Slave In) - Data from master to slave(s) (Master In/Slave Out) - Data from slave(s) to master SCK (Shift Clock) - Clock signal generated by master SS or CS (Slave Select / Chip Select) - Enable bit for slave devices

SPI Data Formatting The speed, data format (MSB/LSB 1st), error correction, etc. is entirely device dependent There are no packets, read/write, address, etc. The Master controls everything This allows for much faster operation than I2C! (ie. NRF24 can operate at up to 10 Mbps!) SD Cards can do SPI

SPI Data Flow Shift Register MOSI (SDO) (SDI) SCK Shift Register Buffer Register Buffer Register CLK GEN SPI Master CS (SS) SPI Slave

SPI Order 1. Master asserts (chip) slave select 2. Master primes data (from buffer) with first bit in shift reg. 3. Master asserts clock 1.shifts 1 bit out of master register on one end 2.shifts 1 bit into shift register on slave end 3.shifts 1 bit out of slave register into master 4.shifts 1 bit into master on opp. end of out bit 4. Master desserts clock 5. Primes data (from buffer),repeat 3 6. When done, deassert chip(slave) select

SPI Common Bus Decoder selects appropriate CS for device Pros: Fast, Direct Cons: Requires more pins/traces SPI Master MOSI SCK Decoder SPI Slave 0 SPI Slave 1 SPI Slave 2 SPI Slave 2

SPI Daisy Chain Common CS line Pros: SPI Master SPI Slave 0 Fewer wires MOSI SPI Slave 1 Cons: SCK Slower! SPI Slave 2 SPI Slave 2

Things to Keep In Mind For every bit shifted out, there is one shifted in and visa versa (As old TA says, It s like a chainsaw. ) To read data, dummy shifts may sometimes be necessary Since there is no set protocol, read datasheets! Specify minimum timing (SPI may be faster than I2C) Specify data format (Not just 1-byte packets always)

PSoC SPI Implementation Everything comes in, goes out through shift register Tx Buffer is used to load the shift register Rx Buffer is used to pull data from shift register Control/Status Register keeps track of buffer(s) status, SPI mode, data format

SPI Sequence on PSoC 1) Assert CS (bring low) 2) Make sure Tx Buffer is empty (TxBufferEmpty 3) Load Tx Buffer with byte to transmit (clears TxBufferEmpty bit) 4) Shift Register is loaded from Tx Buffer (sets TxBufferEmpty bit) 1) Can now load Tx Buffer with another byte to transfer (will happen immediately after current Potentially faster) 5) For each bit, SCK is generated to shift it out on MOSI and shift in bit on 6) Ater all bits transmitted/received, shift register is transferred to Rx Buffer, Tx Buffer goes to shift reg. 1) Sets RxBufferFull & SPIDone bits 2) Can trigger interrupt or poll flags (Polling is slower ~ 1MHz max) 7) Bring CS high Pay attention in the NRF24 Template Project!

NRF24L01 2.4 GHz Radio All low level things (sync., framing, error checking, retransmission, etc.) Divides ISM spectrum into 126 sub-channels Cheap (~$2 each) 3.3V Part (NOT 5V!!! USE LD4391 regulator for +3.3V) However, pins are 5V tolerant (weird, right?) Uses SPI for communication Sender & Receiver configs. must match

NRF24 Configuration Config. happens like thermostat chip Command Byte + Argument Byte(s) (Table 20 pg. 51 in datasheet) R_REGISTER/W_REGISTER differ by 1 bit R: 000A AAAA where A AAAA is address of register W: 001A AAAA where A AAAA is address of register Section 9.1 Shows Register Map Note, some registers, like pipe address registers are multi-byte registers Writing certain values to certain registers configures things like auto. acks, payoad size, crc length, rf channel, rf speed, etc. Data is sent/received through addressable pipes TX pipe is used for sending data (Only 1) RX pipe(s) used for receiving data (RX pipe address must match senders TX pipe address!) 6 RX pipes Can act as hub for up to 5 radios Pipes are actually FIFO memory on chip (more in a second)

NRF24 Configuration for Lab To properly talk to the receiver, the nrf must be configured the same, and the pipe addresses must match for sender and receiver Set the number or retransmissions to 15 with a 4000 us delay between retransmissions Set the nrf24l01 to use channel 0x60 Set the data rate to 250 kbps at maximum power level Set the transmit address to 0xc2c2c2c2c2 Set the receive address of data pipe 0 to also be 0xc2c2c2c2c2 Set the receive address of the transmitter (RX_ADDR_P1) to be 0xe7e7e7e7e7 Set the payload size to be fixed at 8 bytes Turn on auto-acknowledge for your data pipes Turn on your data pipes Set the config register to do 2-byte CRCs, power up the radio, and put it in transmit mode

Retransmit Example Set the number or retransmissions to 15 with a 4000 us delay between retransmissions From Register Map in datahseet: 04 is SETUP_RETR register Bits 7:4 are ARD (Automatic Retransmission Delay) 0000 wait 250 us, 0001 wait 500 us, 1111 wait 4000 us (Each increment adds 250 us to delay) Bits 3:0 are ARC (Auto. Retransmit Count) 0000 Disable retransmit 0001 1 automatic. retransmit, 0002 2 auto. retrans,, 1111 15 automatic. retransmits So, we would want to write 0xFF to register 04 for 15 auto. retransmits that are spaced 4000 us apart This would be 2 SPI writes 1 st Byte: W_REGISTER at address 04 (001A AAAA 0010 0100 0x24) Note in the API this is already defined as NRF_WRITE_SETUP_RETR 2 nd Byte: ARD = 1111, ARC = 1111 1111 1111 0xFF

Data Flow To send data: First send the NRF_WRITE_PAYLOAD byte (0xA0), followed by a number of bytes equal to the payload size (8 in our case) After sending, poll the IRQ bit and wait for it to go to zero. This indicates either a successful transmission (due. to auto ACK) or that the max. number of retries has been reached Proper error checking would read the STATUS (07) register and check the TX_DS or MAX_RT bits to see which interrupt caused the IRQ WE DON T HAVE TO FOR THIS LAB!!! After the IRQ bit goes low, clear the appropriate flags by writing 1 s to them in the nrf24l01 status register (07).

Data Format For Lab You should send the string #: YYY.Y to the receiver, where # is your lab station letter (ask if you don t know) and YYY.Y is the string you would display (minus the degree symbol) # is the lab station letter: A is group on far wall closest to whiteboard B is group immediately to their right Wraparound to the middle table from back wall Wraparound to the printer and work back towards wall Group closest to cabinets would have highest letter Sample hex file sends #: 381.0 Use to test nrf24 wiring!