AN2358. Manchester Decoder Using PSoC 1. Introduction. Contents. Manchester Code Principle



Similar documents
Digital Multiplexer and Demultiplexer. Features. General Description. Input/Output Connections. When to Use a Multiplexer. Multiplexer 1.

PSoC Creator Component Data Sheet. Calculation accuracy 0.01 C for -200 C to 850 C temperature range

Thermistor Calculator. Features. General Description. Input/Output Connections. When to use a Thermistor Calculator 1.10

Scanning Comparator (ScanComp) Features. General Description. Input/Output Connections. When to Use a Scanning Comparator. clock - Digital Input* 1.

DESIGNING SECURE USB-BASED DONGLES

PSoC Programmer Release Notes

PSoC Programmer Release Notes

Designing an efficient Programmable Logic Controller using Programmable System On Chip

Manchester Encoder-Decoder for Xilinx CPLDs

PSoC Programmer Release Notes

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

1-Mbit (128K x 8) Static RAM

CAPACITIVE SENSING MADE EASY, Part 2 Design Guidelines

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

AN3998 Application note

Flexible Active Shutter Control Interface using the MC1323x

HEF4021B. 1. General description. 2. Features and benefits. 3. Ordering information. 8-bit static shift register

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

A New Paradigm for Synchronous State Machine Design in Verilog

Comparison of 2.4-GHz proprietary RF and Bluetooth 4.0 for HIS applications Page 1 of 6

PSoC Programmer Release Notes

Simplifying System Design Using the CS4350 PLL DAC

White Paper Utilizing Leveling Techniques in DDR3 SDRAM Memory Interfaces

USER GUIDE EDBG. Description

Using Altera MAX Series as Microcontroller I/O Expanders

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Multiple clock domains

CHAPTER 11: Flip Flops

256K (32K x 8) Static RAM

DS2155 T1/E1/J1 Single-Chip Transceiver

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Enhancing High-Speed Telecommunications Networks with FEC

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

DM54161 DM74161 DM74163 Synchronous 4-Bit Counters

MAX II ISP Update with I/O Control & Register Data Retention

74F168*, 74F169 4-bit up/down binary synchronous counter

GETTING STARTED WITH PROGRAMMABLE LOGIC DEVICES, THE 16V8 AND 20V8

HEF4013B. 1. General description. 2. Features and benefits. 3. Applications. 4. Ordering information. Dual D-type flip-flop

AN2680 Application note

Programming Audio Applications in the i.mx21 MC9328MX21

Fairchild Solutions for 133MHz Buffered Memory Modules

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

DM74LS193 Synchronous 4-Bit Binary Counter with Dual Clock

Counters and Decoders

DIGITAL COUNTERS. Q B Q A = 00 initially. Q B Q A = 01 after the first clock pulse.

DM74LS169A Synchronous 4-Bit Up/Down Binary Counter


SDLC Controller. Documentation. Design File Formats. Verification

RETRIEVING DATA FROM THE DDC112

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

SINGLE-SUPPLY OPERATION OF OPERATIONAL AMPLIFIERS

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

DM74LS191 Synchronous 4-Bit Up/Down Counter with Mode Control

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Lecture 8: Synchronous Digital Systems

Rotary Encoder Interface for Spartan-3E Starter Kit

INTEGRATED CIRCUITS. NE558 Quad timer. Product data Supersedes data of 2001 Aug Feb 14

AN3265 Application note

HEF4011B. 1. General description. 2. Features and benefits. 3. Ordering information. 4. Functional diagram. Quad 2-input NAND gate

74HC377; 74HCT General description. 2. Features and benefits. 3. Ordering information

Module 3: Floyd, Digital Fundamental

Implementing an In-Service, Non- Intrusive Measurement Device in Telecommunication Networks Using the TMS320C31

Kvaser Mini PCI Express User s Guide

Sample Project List. Software Reverse Engineering

Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

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

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

PAC52XX Clock Control Firmware Design

2015 Qualcomm Technologies, Inc. All rights reserved.

6-BIT UNIVERSAL UP/DOWN COUNTER

Video over USB. Why Video over USB? By Ashwini Govindaraman, Cypress Semiconductor Corp.

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

Quad 2-input NAND Schmitt trigger

The components. E3: Digital electronics. Goals:

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Source-Synchronous Serialization and Deserialization (up to 1050 Mb/s) Author: NIck Sawyer

AN4646 Application note

a8251 Features General Description Programmable Communications Interface

AD9125-EBZ Quick Start Guide

Microprocessor & Assembly Language

8-bit binary counter with output register; 3-state

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

QorIQ espi Controller Register Setting Considerations and Programming Examples

Low-power configurable multiple function gate

74HC175; 74HCT175. Quad D-type flip-flop with reset; positive-edge trigger

LatticeECP3 High-Speed I/O Interface

Modeling Latches and Flip-flops

SN54HC191, SN74HC191 4-BIT SYNCHRONOUS UP/DOWN BINARY COUNTERS

21152 PCI-to-PCI Bridge

PCM Encoding and Decoding:

MicroMag3 3-Axis Magnetic Sensor Module

White Paper Streaming Multichannel Uncompressed Video in the Broadcast Environment

Web Service. User Manual

Introduction to PCI Express Positioning Information

Transcription:

AN2358 Author: Philippe Larcher Associated Project: Yes Associated Part Family: CY8C29x66, CY8C27x43, CY8C24X94, CY8C24x23A, CY8C23x33, CY8C21x34, CY8C21x23 Software Version: PSoC Designer 5.4 Related Application Notes: None This application note describes how to build a Manchester Decoder using two digital blocks and some combinatorial logic of the PSoC 1 device. After it is initialized, the decoder requires no firmware intervention. Clock and serial data recovered by the receiver can serve as inputs for a number of serial data communication methods including SPI and pattern recognition circuits. Contents Introduction... 1 Manchester Code Principle... 1 Manchester Decoder - The Digital Way... 2 PSoC 1 Implementation... 3 XOR Gate... 3 D Flip-Flop... 3 Delay Counter... 4 Place and Route... 5 Porting the Manchester Decoder... 6 Hardware... 6 Firmware Initialization... 6 Synchronizing on the Right Edge... 6 Initial State and First Bit Mismatch... 6 Auto Synchronization... 7 Summary... 8 Worldwide Sales and Design Support... 10 Introduction Manchester code is widely used in communication systems because of its simplicity: a single signal conveys data and clock information without the need for high-level protocol. Additional benefits include self-synchronization, zero DC components, and independence from transmission media. A Manchester link consists of a transmitter (Manchester encoder) and a receiver (Manchester decoder). Manchester decoding is more complex because it requires extracting clock and data information from a single signal. This application note describes a Manchester decoder based on digital reconstruction; implemented with only two PSoC 1 digital blocks; it is portable to a PSoC 1 device family which contains at least two digital blocks, such as CY8C29x66, CY8C27x43, CY8C24x94, CY8C24x23A, CY8C23x33, CY8C21X34, and CY8C21x23. Decoding speed is programmable and can easily achieve 200 kbps or more. Manchester Code Principle Manchester code embeds clock information with data in a very simple way: each bit is transmitted with a transition in the middle of bit time. For a 0, transition is 0 to 1, for a 1, transition is 1 to 0 (see Figure 1). www.cypress.com Document No. 001-17375 Rev. *E 1

Figure 1. Manchester Coding for Bit Values 0 and 1 bit - time 0 1 When transmitting successive bits, additional transitions are inserted between bits to satisfy the mid-bit transition rule, as represented in Figure 2. Figure 2. Transmitting Multiple Bits 0 1 1 0 0 1 0 0 The next step is to simply rename Polarity_invert to Serial Data Out and XOR Polarity_invert to Serial Clock Out, following which the Manchester receiver is complete (see Figure 5). Some considerations are still required for the first transition versus the idle state of, which are discussed at the end of this application note, after the description of implementation. Figure 5. Manchester Receiver Outputs 0 1 1 0 0 3/4 bit-time 3/4 bit-time 3/4 bit-time 3/4 bit-time Serial Data Out Serial Clock Out 0 1 1 0 0 Manchester Decoder - The Digital Way The method described here is not based on the direction of mid-bit edge. It is based on the fact that the bit value is present during the first half of bit time, prior to the transition edge. If a delay of three-fourths bit time is triggered by the incoming mid-bit transition, the value captured at the end of the delay tells the next bit value (see Figure 3). Figure 3. Capturing the Next Bit Value Serial Manchester Data 0 1 1 0 3/4 bit-time 1 1 0 Note If the next bit value is 1, the receiver sets a signal to invert the input bit stream polarity. Therefore, the next signal transition appears as a low-to-high transition as shown in Figure 4. If the next bit value is 0, the receiver resets the inverted signal. Figure 4. Inverting Mid-Bit Transition 0 1 1 0 0 3/4 bit-time 3/4 bit-time 3/4 bit-time 3/4 bit-time Polarity_invert Xor Polarity_invert www.cypress.com Document No. 001-17375 Rev. *E 2

PSoC 1 Implementation The previous description translates into the following block diagram. Figure 6. Manchester Receiver Block Diagram Trig Clk Delay FF Serial Clock Out Serial Data Out As shown in the block diagram, the following three functions are required: A XOR gate to generate the Serial Clock Out A D Flip-Flop to register the state of when the delay expires A counter to generate a three-fourths bit time delay, triggered by the XOR-gate output (always a 0-to-1 transition). The following sections discuss the PSoC 1 implementation for these functions. XOR Gate This function is easily implemented with one of the Look- Up Tables (LUT) placed on output rows and does not require further explanation. D Flip-Flop There is no D Flip-Flop function directly available in the PSoC 1 architecture. However, it is possible to implement a conditional T Flip-Flop with a digital block configured as a counter. If the counter period is set to 1 and the compare value to less than or equal to 0, then the compare out signal toggles upon each clock cycle when enable is high. With this arrangement, we just need to connect the enable signal to the XOR gate output, and the Polarity_invert signal only toggles when there is a change (0 to 1 or 1 to 0) in the input bit value, as seen in Figure 7. Figure 7. Emulation of D Flip-Flop with Counter and Enable 0 1 1 1 0 (Counter En.) En. CNTR8 Pol_invert (Pol_invert) (Period=1, Compare=0) www.cypress.com Document No. 001-17375 Rev. *E 3

Delay Counter The XOR gate output can be used as an enable signal to start counting. However, its duration may be only one-half bit time wide, which is insufficient to cover a three-fourths bit time counting period. The problem is solved by OR-ing the initial enable signal with a counter compare out signal, thus extending the enable duration over the whole delay period, as shown in Figure 8. The combinatorial OR gate is implemented with a row LUT. Figure 8. Three-Fourths Bit Time Delay Generation 0 1 1 0 Counter Enable En. CNTR8 VC3 End_of_Delay Delay Comp_Out 3/4 bit-time Note that the polarity control is updated on the rising edge of, causing the enable signal to be reset one clock cycle prior to. This prevents any edge crossing. VC3 (counter clock frequency) counts three-fourths of bit time; this requires a VC3 clock at least four times the bit rate. However, tolerance must be added to cope with intrinsic precision and jitter of the transmitter and receiver. For example, if the transmission bit rate is 100 kbps, then the clock frequency for the delay counter is 1.6 MHz, that is, VC3 = SysClk/15. Figure 9 shows the adequate value of period and compare out for a three-fourths bit time delay. These values depend only on the selected oversampling rate and do not need to be changed when changing the transmission speed through VC3. Selecting an x16 oversampling rate gives more than 10 percent frequency tolerance on each side and is the retained value for the design. Figure 9. Period and Compare Out Values for Delay Counter 10 us (100 Kbps) 3/4 VC3 (1.6 MHz) Period counter 12 11 10 9 8 7 6 5 4 3 2 1 0 12 Comp_Out () www.cypress.com Document No. 001-17375 Rev. *E 4

Place and Route Figure 10 represents the whole Manchester receiver function. The PSoC 1 device offers several possibilities to internally route back block output signals to block input (as required, for example, for ). However, internal feedbacks may create placement or pinout constraints if the receiver is imported into an existing design. Therefore, as shown in Figure 11, external feedbacks are recommended, at the cost of three additional input pins. Figure 12 is a screenshot of the User Module placement and routing in the associated PSoC Designer project. Figure 10. Manchester Receiver Final En. CNTR8 En. CNTR8 VC3 Delay Pol_invert Figure 11. Manchester Receiver for Flexible Place and Route _fb external feedback external feedback en_dly en_dly_fb En. CNTR8 En. CNTR8 VC3 Delay Pol_invert www.cypress.com Document No. 001-17375 Rev. *E 5

Figure 12. Manchester Receiver, Device Editor Interconnect View Porting the Manchester Decoder The project associated with this application note can be used independently or can be plugged into a larger application. The setup is simple. Hardware Externally connect and _fb, en_dly and en_dly_fb. Set VC3 frequency to 16 times the serial bit rate. Firmware Initialization Start the Delay counter and the Pol_invert counter. Readjust the Pol_invert counter period to 1 (correct startup requires initial period to be 0 ). Synchronizing on the Right Edge For example, this occurs if the idle state of the line is low and the first received bit is a 1 (or inversely), or, if the receiver is randomly enabled in the middle of a packet transmission. Such initial conditions translate into synchronization aliasing. However, a worthy receiver should be able to dynamically recover from this situation without manual intervention. Initial State and First Bit Mismatch Figure 13 shows a situation where the idle state of the serial input is low, and the first bit sent by the transmitter is a 1. In good faith, the receiver considers the first transition to be a mid-bit transition, and starts extracting the serial data from this point. Figure 14 shows that faulty synchronization stops as soon as a 0 is received. This causes the receiver to resynchronize correctly and definitely, because a 1-then- 0 bit sequence (and 0-then-1 ) only exhibits mid-bit transitions and no inter-bit transitions. This forces receiver realignment on the right edge. Until now, the Manchester receiver behavior analysis assumed that the first detected edge was at mid-bit transition. However, there are cases where the first transition seen by the receiver is an inter-bit transition. Figure 13. Idle State Low and First Received Bit is 1 1 1 0 1 0 0 0 1 receiver synchronized on wrong edge receiver is resynchronized www.cypress.com Document No. 001-17375 Rev. *E 6

The same sequence is repeated when the idle state of the line is high and the first received bit is a 0 (see Figure 14). In this case, the correct synchronization starts with the first 1 that is received. Figure 14. Idle State High and First Received Bit is 0 0 0 1 0 1 1 1 0 receiver synchronized on wrong edge receiver is resynchronized Synchronization errors due to hazardous enabling of the receiver during packet transmission create the same situations as described above, and are auto-recovered in the same way. Auto Synchronization As discussed in the previous section, the condition for correct synchronization is simple. The transmitter must ensure either one of the following: The first bit sent complies with the idle state of the line; for example, always start messages with a 0 bit when the idle state is low. Or, send a 0 to 1 (or 1 to 0) preamble to guarantee a correct synchronization in any situation. The preamble can extend beyond these two bits to add other benefits such as speed synchronization, pattern recognition, and so on. www.cypress.com Document No. 001-17375 Rev. *E 7

Summary In this application note, a robust Manchester Decoder has been implemented using two PSoC 1 digital blocks. The recovered serial clock and serial data can feed a number of serial data communication methods including SPI and pattern recognition circuits. About the Author Name: Title: Background: Philippe Larcher Field Application Engineer, Cypress France 25 years of activity in computer and electronic system design. Authored several application notes, articles, and the book VHDL, Introduction à la Synthèse Logique. www.cypress.com Document No. 001-17375 Rev. *E 8

Document History Document Title: Manchester Decoder Using PSoC 1 - AN2358 Document Number: 001-17375 Revision ECN Orig. of Change Submission Date Description of Change ** 1351984 HMT 08/06/2007 Entering existing application note in the spec system. *A 1629363 JVY 10/15/2007 Updated to new template. *B 2818666 XKJ 12/01/2009 Changed title to Manchester Decoder Using PSoC 1. Updated content to be compatible with PSoC Designer 5.0. *C 3102584 DASG 12/06/2010 The project is updated to PSoC Designer 5.1 In the project, the Counter (pol) period is set to 1. In the project's main _fb value is corrected to P0_5 Pin (Line 53). *D 4221763 RJVB 12/16/2013 Updated to new template. Completing Sunset Review. *E 4622492 ASRI 01/13/2015 Updated Software Version as PSoC Designer 5.4 in page 1. Updated Related Application Notes (Removed references of AN2281, AN2325 as these ANs are obsolete). Updated attached associated project to PSoC Designer 5.4. www.cypress.com Document No. 001-17375 Rev. *E 9

Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. Products Automotive Clocks & Buffers Interface Lighting & Power Control Memory PSoC Touch Sensing USB Controllers Wireless/RF cypress.com/go/automotive cypress.com/go/clocks cypress.com/go/interface cypress.com/go/powerpsoc cypress.com/go/plc cypress.com/go/memory cypress.com/go/psoc cypress.com/go/touch cypress.com/go/usb cypress.com/go/wireless PSoC Solutions psoc.cypress.com/solutions PSoC 1 PSoC 3 PSoC 4 PSoC 5LP Cypress Developer Community Community Forums Blogs Video Training Technical Support cypress.com/go/support PSoC is a registered trademark of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone : 408-943-2600 Fax : 408-943-4730 Website : www.cypress.com Cypress Semiconductor Corporation, 2007-2015. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as specified above is prohibited without the express written permission of Cypress. Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress product in a life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. Use may be limited by and subject to the applicable Cypress software license agreement. www.cypress.com Document No. 001-17375 Rev. *E 10