Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication



Similar documents
Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

Implementing SPI Communication Between MSP430 G2452 and LTC ADC

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

A DIY Hardware Packet Sniffer

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI

ET-BASE AVR ATmega64/128

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

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

SafeSPI - Serial Peripheral Interface for Automotive Safety

DECT Module UM-9802 Datasheet

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

GTS-4E Hardware User Manual. Version: V1.1.0 Date:

Serial Communications

RL78/G12 APPLICATION NOTE. Serial Array Unit (CSI Master Communication) Introduction. Target Device. R01AN1369EJ0100 Rev Mar.

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

Application Note. Introduction. J1850 Overview. AN1212/D Rev. 1, 11/2001

CAN bus board. EB018

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

WICE-SPI Hardware Operation Manual

Arduino DUE + DAC MCP4922 (SPI)

HT1632C 32 8 &24 16 LED Driver

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Serial Communications

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

HT46R14A Single Phase AC Induction Motor Frequency Converter Application

Interfacing Analog to Digital Data Converters

AVRprog. programmer by MikroElektronika

Design and Functional Verification of A SPI Master Slave Core Using System Verilog

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

MicroMag3 3-Axis Magnetic Sensor Module

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Using the HT1632 for Dot Matrix LED Displays

Allows the user to protect against inadvertent write operations. Device select and address bytes are Acknowledged Data Bytes are not Acknowledged

Application of Wireless Sensor Network and GSM Technology: A Remote Home Security System

Using Altera MAX Series as Microcontroller I/O Expanders

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

FR FAMILY MB91460 SPI - DAISY CHAIN COMMUNICATION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Chapter 13. PIC Family Microcontroller

Embedded Systems Design Course Applying the mbed microcontroller

Design of a High Speed Communications Link Using Field Programmable Gate Arrays

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

LOCAL INTERCONNECT NETWORK (LIN)

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

PART B QUESTIONS AND ANSWERS UNIT I

TS5010 TeraTune Programmable Bandpass Filter

DVPPF02-H2. PROFIBUS DP Slave Communication Module Application Manual

DATASHEET. DIABLO16 Processor. Embedded Graphics Processor. Document Date: 7 th November 2013 Document Revision: 1.3

SPI I2C LIN Ethernet. u Today: Wired embedded networks. u Next lecture: CAN bus u Then: wireless embedded network

Raspberry Pi. Hans- Petter Halvorsen, M.Sc.

AN974 APPLICATION NOTE

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

Arbitration and Switching Between Bus Masters

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

FPGA INTEGRATION MANUAL SATURN-SIL 2 MODULES. Dictionary Code. Edition 01. Revision 00. Number of pages 18

The Programming Interface

Dolphin In-Circuit programming Updating Firmware in the field

JTAG-HS2 Programming Cable for Xilinx FPGAs. Overview. Revised January 22, 2015 This manual applies to the HTAG-HS2 rev. A

The Answer to the 14 Most Frequently Asked Modbus Questions

Serial port interface for microcontroller embedded into integrated power meter

MTS Master Custom Communications Protocol APPLICATION NOTES

Embedded Ethernet Interface Using Arm Processor

Android Controlled Based Interface

Patient Health Monitoring Using Wireless Body Area Network

Microcontrollers in Practice

CSE2102 Digital Design II - Topics CSE Digital Design II

EC313 - VHDL State Machine Example

Microtronics technologies Mobile:

USER GUIDE EDBG. Description

Bluetooth UART/RS232 Module

Information Board User s Guide

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

I.S. 1 remote I/O system Redundant coupling via PROFIBUS DP

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

TRILOGI 5.3 PLC Ladder Diagram Programmer and Simulator. A tutorial prepared for IE 575 by Dr. T.C. Chang. Use On-Line Help

SM1231 USER GUIDE SM1231 RF MODULE USER GUIDE

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

Accurate Measurement of the Mains Electricity Frequency

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Internal Oscillator. I 2 C Interface. SPI Interface. Controller. Internal Registers Port Controller. Eight I/O Pins. Figure 1.

The Secrets of RS-485 Half-duplex Communication

Smartphone Quick-Jack Solution FASTER TO PRODUCT FASTER TO MARKET

Using the AnyBus -X Gateway to Communicate between a DVT camera and a Profibus Master

Secure My-d TM and Mifare TM RFID reader system by using a security access module Erich Englbrecht (info@eonline.de) V0.1draft

Operating Systems. Lecture 03. February 11, 2013

W25Q80, W25Q16, W25Q32 8M-BIT, 16M-BIT AND 32M-BIT SERIAL FLASH MEMORY WITH DUAL AND QUAD SPI

Software User Guide UG-461

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

DS1307ZN. 64 x 8 Serial Real-Time Clock

STK User Guide

Lab Experiment 1: The LPC 2148 Education Board

DAC Digital To Analog Converter

VisorALARM-Manager Application Quick Guide. (Ver. 1.3) Dm 380-I. V:3.0

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

DS2401 Silicon Serial Number

Transcription:

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication D/N: HA0150E Introduction This application explains how to use two I/O lines on the HT46R46 to implement half-duplex SPI communication. SPI Communication Protocol The Master and Slave use their I/O ports to communicate with each other using a simulated SPI protocol, the following is the method used: DIR: SPI communication direction control bit. Setup using the switch which is connected to PA.7. When the switch is set to zero then the master is reading and the slave is writing. When the switch is set high then the master is writing and the slave is reading. INC: When this bit is high and continual transmission is taking place, the address will automatically increase by one. (must remain no temporary use) Address: Address bit (must remain no temporary use) Data: 8-bit data 1

Fig. 1 Master control clock signal SCK, device select CS (consult the above figure /SS condition) and SPI communication baud rate. In this application, each time the key (connected to PD.) is pressed, the master and slave will conduct communication. The data received will be displayed on the PB port display. 2

Hardware Block Diagram Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication Master (HOST) Block Diagram Fig. 2 Slave Hardware Block Diagram Fig. 3 3

Hardware Circuit Diagram Fig. 4 4

Software Flowchart Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication Master (HOST) Program Flowchart Start MCU Initialise RAM and I/O Port Master Setup CS, CLK, SDO I/O Port as Output, SDI I/O Port as Inputs KEY is Pressed N Y Set DIR bit to Control SPI to READ or WRITE Master to SPI Communication Routine SPI_HOST_TO_SLAVE N F_SPI_OK = 1 Y Y Master READ Data N Master Received Data Output on PB Port Display WRITE_RAM bit Move and Prepare Next Output Bit Fig. 5 5

Slave Program Flowchart Fig. 6 6

SPI_HOST_TO_SLAVE Subroutine Flowchart 7 Fig. 7

SPI_SLAVE_TO_HOST Subroutine 8 Fig. 8

Program Flow Description After Power-on, the master and the slave will conduct their respective initialization procedures. The SPI communication will be initiated by the master. When the slave responds to the master the I/O port will be used to simulate SPI protocol half-duplex communication. In this application each time the key connected to PD.0 is pressed, the master will conduct SPI communication. This is implemented by the master using the device select signal (CS), and the SPI clock signal (CLK), the read/write control bit (SDIR). When the slave receives CS, CLK and SDIR signals it will respond to the master. Each time an SPI communication has ended, the master and the slave will determine if the data is to be displayed on the PB port display. Then the program will return and continue with the next SPI communication. In the SPI serial communication program, the master and the slave both input data on SDI on the rising edge of SCK. Data is outputted on the SDO line on the falling edge of SCK. Each SCK clock period transmits 1-bit of data. This is repeated 8 times to complete an 8-bit data serial transmission. During this time, according to the condition of SDIR, the direction of the communication is setup. If SDIR = 1 then the data communication is from master to slave or if SDIR is = 0 the data communication is from slave to master. This application program I/O timing is shown as follows in Fig. 9: Fig. 9 SPI Communication Flow 9

Program Variables and Communication Setup Description CS: SPI serial communication device select signal (consult Fig. 9 /SS condition). The master and slave CS are connected. The master controls the CS signal, and the slave checks its condition. The CS line is active when low. SCK: SPI communication clock signal (consult Fig. 9 SCK condition). The master and the slave SCK are connected. The master controls the SCK line and controls the serial transmission speed. The slave checks the condition of the SCK signal and responds to the master with SPI communication. SDO: SPI serial communication output signal (consult Fig. 9 MOSI condition). The master and slave output data on SDO on the falling edge of SCK. SDI:SPI serial communication input signal (consult Fig. 9 MISO condition). The master and the slave SCK receive data on SDI on the high going edge of SCK. SDIR: Setup the SPI serial communication data transfer direction. When SDIR is zero, the master will read from the slave and the communication direction is from slave to master. When SDIR is high, the master writes to the slave and the data communication direction is from master to slave. C_BaudRate: The master will setup the SPI serial communication data transmission rate. In this application fsys is 4MHz and the TIMER clock source is fsys/4=1mhz. If it is required to implement a 4800 transmission rate, then 1/4800 = 208us is required to transmit 1-bit of data. Therefore the SCK clock period is also 208us. Then setup the TIMER to have a period of 104us after which the SCK bit can change giving a SCK clock period of 208us. Therefore when C_BaudRate = 104us the transmit rate is 4800. In the same way when C_BaudRate = 52, the SCK clock period is 104us and the transmit rate is 9600. Other transmit rates can be similarly calculated. The above constants are defined in the user_setting.inc file. In the file, SDIR and C_BaudRate are setup in the master. When implementing SPI serial communication, the master SDO signal and the slave SDI signal are connected. The master SDI signal and the slave SDO line are connected. WRITE_RAM: SPI serial communication output data Buffer READ_RAM: SPI serial communication input data Buffer CMD_RAM: SPI serial communication CMD data Buffer Program Function Description INI_RAM: Initialise RAM subroutine SPI_HOST_TO_ SLAVE: SPI serial communication master subroutine SPI_SLAVE_TO_HOST: SPI serial communication slave subroutine SET_BAUDRATE: SPI serial communication transmit frequency - baud rate - setup subroutine 10