Shadow Registers Datasheet ShadowRegs V 1.1. Features and Overview

Similar documents
8 to 1 Analog Multiplexer Datasheet AMux8 V 1.1. Features and Overview

For one or more fully configured, functional example projects that use this user module go to

CapSense I 2 C/SPI Timer Flash RAM

LPF (Optional) CY8C24x93. Without LPF and ISR to 3* With LPF only** to 3* With ISR only to 3*

CY7C603xx CYWUSB

Programmable Gain Amplifier Datasheet PGA V 3.2. Features and Overview

4 to 1 Analog Multiplexer Data Sheet

Supported Devices: CY8C28x13, CY8C28x33, CY8C28x43, CY8C28x45, CY8C28x52, CY8C21x45, CY8C22x45, CY8C24x93. CY8C24x

Preliminary. Gas Sensor Analog Front End Datasheet GasSensorAFE V Features and Overview. This datasheet contains Preliminary information.

Use the Status Register when the firmware needs to query the state of internal digital signals.

Programmable Threshold Comparator Data Sheet

This optional pin is present if the Mode parameter is set to SyncMode or PulseMode. Otherwise, the clock input does not show.

Incremental ADC Data Sheet

Use the Status Register when the firmware needs to query the state of internal digital signals.

DMX512 Receiver Datasheet DMX512Rx V 1.0. Features and Overview

This optional pin is present if the Mode parameter is set to SyncMode or PulseMode. Otherwise, the clock input does not show.

Writing to Internal Flash in PSoC 3 and PSoC 5

24-Bit Pseudo Random Sequence Generator Data Sheet

Voltage Reference (Vref) Features. General Description. Input/Output Connections. When to Use a Vref Voltage references and supplies

CY8C29/27/24/23/21xxx, CY8CLED02/04/08/16, CY8CLED0xD, CY8CLED0xG, CY8C28x45, CY8CPLC20, CY8CLED16P01, CY8C28xxx. Main UM

Comparator Datasheet CMP V 1.1. Features and Overview

HX2VL Development Kit Guide. Doc. # Rev. *A

Cypress HX2VL Configuration Utility Blaster User Guide

PSoC Blocks. CY8C20xx6/6A/6AS/6H/6L, CY8C20xx7/7S, CY7C643xx, CY7C604xx, CYONS2xxx, CYONSxNxxxx, CYRF89x35, CY8C20065, CY8C24x93, CY7C69xxx

16-Bit Hardware Density Modulated PWM Data Sheet

Filter_ADC_VDAC_poll Example Project Features. General Description. Development Kit Configuration

HX2VL Development Kit Guide. Doc. # Rev. **

PSoC 1 I 2 C Bootloader

Supported devices: CY8C29x66, CY8C27x43, CY8C28xxx, CY8C24x23, CY8C24x33, CY8C21x23, CY8C21x34, CY8C21x45, CY8C22x45, CY8C24x94

PSoC 4 Low Power Comparator (LPComp) Features. General Description. When to Use a LPComp 2.0. Low input offset. User controlled offset calibration

PSoC Programmer 3.12 Release Notes

Comparator (Comp) Features. General Description. When to use a Comparator 1.60

THIS SPEC IS OBSOLETE

Release Notes SRN065 PSoC Programmer Version Release Date: November 9, 2009

GPIF II Designer - Quick Start Guide

32-Bit Counter Datasheet Counter32 V 2.5. Features and Overview

Cypress HX2VL Configuration Utility Blaster User Guide

Reviving Bit-slice Technology in a Programmable Fashion

CE56273 Associated Part Families: CY8C38xx/CY8C55xx Software: PSoC Creator Related Hardware: CY8CKIT-001 Author: Anu M D

PSoC Creator Component Datasheet

Next-Generation Hot-Swap Controllers

Use the IDAC8 when a fixed or programmable current source is required in an application.

AN SIO Tips and Tricks in PSoC 3 / PSoC 5. Application Note Abstract. Introduction

CE PSoC 4: Time-Stamped ADC Data Transfer Using DMA

For one or more fully configured, functional example projects that use this user module go to

THIS SPEC IS OBSOLETE

PSoC Programmer Release Notes

CYClockMaker Programming Kit Guide CY3675. Doc. # Rev. **

FTG Programming Kit CY3670. Spec. # Rev. *C

For one or more fully configured, functional example projects that use this user module go to

The color of the Clock component waveform symbol will change based on the clock's domain (as shown in the DWR Clock Editor), as follows:

This Application Note demonstrates an SPI-LIN slave bridge using a PSoC device. Demonstration projects are included.

CYClockMaker Programming Kit Guide CY3675. Doc. # Rev. *C

PSoC Designer Release Notes

CY3660-enCoRe V and encore V LV DVK Kit Guide

Use the Status Register when the firmware needs to query the state of internal digital signals.

Libraries Guide. Arithmetic Libraries User Guide. Document #: Rev. *A

The following table lists user modules used in this code example and the hardware resources occupied by each user module.

CE58957 demonstrates how to implement the fade and toggle feature to the backlight LEDs of CapSense buttons.

Clock Programming Kit

THIS SPEC IS OBSOLETE

This optional pin is present if the Mode parameter is set to SyncMode or PulseMode. Otherwise, the clock input does not show.

AN EZ-USB FX3 I 2 C Boot Option. Application Note Abstract. Introduction. FX3 Boot Options

One 32-bit counter that can be free running or generate periodic interrupts

FM3 MB9B100A/300A/400A/500A Series Inverter Solution GUI User Guide

EZ I 2 C Slave. Features. General Description. When to use a EZ I 2 C Slave 1.50

The AMuxSeq is capable of having between 2 and 32 analog inputs. The paired inputs are present when the MuxType parameter is set to "Differential.

Programmer User Guide

This section describes the various input and output connections for the Voltage Fault Detector.

Use the Status Register when the firmware needs to query the state of internal digital signals.

EZ-USB FX3 Development Kit Guide

This section describes the various input and output connections for the SysInt Component.

AN1090. NoBL : The Fast SRAM Architecture. Introduction. NoBL SRAM Description. Abstract. NoBL SRAM Operation

Digital Logic Gates. Features. General Description. Input/Output Connections. When to Use a Logic Gate. Input 1. Input 2. Inputs 3-8 * 1.

6 to 14-Bit Delta Sigma ADC DatasheetDelSigMultiV 1.30

Bootloader project - project with Bootloader and Communication components

PSoC 6 Current Digital to Analog Converter (IDAC7)

144-Mbit QDR -II SRAM 2-Word Burst Architecture

1st Order Modulator nd Order Modulator

This section describes the various input and output connections for the Voltage Fault Detector.

Multifunction Serial Interface (PDL_MFS) Features. General Description. When to Use a PDL_MFS Component. Quick Start 1.0

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

Automatic reload of the period to the count register on terminal count

12-Mbit (512 K 24) Static RAM

Base Timer Channel (BT) Features. General Description. When to Use a PDL_BT Component 1.0

PSoC 4 Voltage Comparator (Comp) Features. General Description. When to Use Comparator Low input offset. User controlled offset calibration

Use a DieTemp component when you want to measure the die temperature of a device.

1st Order Modulator nd Order Modulator

Capable of adjusting detection timings for start bit and data bit

Supports one or two address decoding with independent memory buffers. Memory buffers provide configurable Read/Write and Read Only regions

PSoC Creator Quick Start Guide

4K x 8 Dual-Port Static RAM and 4K x 8 Dual-Port SRAM with Semaphores

This input determines the next value of the output. The output does not change until the next rising edge of the clock.

Optional Pause Pulse for constant frame length of 282 clock ticks

Analog Multiplexer (AMux) Features. General Description. Input/Output Connections. When to Use an AMux Single or differential connections

PSoC 4 Current Digital to Analog Converter (IDAC)

Voltage Fault Detector (VFD) Features. General Description. Input/Output Connections. When to Use a VFD. Clock Input 2.30

Comparator (Comp) Features. General Description. When to use a Comparator Low input offset. User controlled offset calibration

PSoC 1 In-Circuit Emulation (ICE) Lite Development Kit Guide CY3215A-DK. Doc. # Rev. *A

7- to 13-Bit Variable Resolution Incremental ADC Datasheet ADCINCVR V 4.00

Transcription:

Datasheet ShadowRegs V 1.1 001-16962 Rev. *H Shadow Registers Copyright 2007-2013 Cypress Semiconductor Corporation. All Rights Reserved. Resources PSoC Blocks API Memory (Bytes) Digital Analog CT Analog SC Flash RAM Pins (per External I/O) CY8C20x34, CY8C21x12, CY8C29/27/24/22/21xxx, CY8C20x36, CY8C20336AN, CY8C20436AN, CY8C20636AN, CY8C20xx6AS, CY8C20XX6L, CY8C20x46, CY8C20x96, CY8C20045, CY8C20055, CY7C64215, CY7C64343, CY7C60413, CY7C603xx, CY8CLED02/04/08/16, CY8CLED0xD, CY8CLED0xG, CY8CTST110, CY8CTST120, CY8CTST200, CY8CTMG110, CY8CTMG120, CY8CTMG2xx, CY8CTMA120, CY8CTMA30xx, CY8C28x45, CY8CPLC20, CY8CLED16P01, CYONS2010, CYONS2011, CYONSFN2051, CYONSFN2053, CYONSFN2061, CYONSFN2151, CYONSFN2161, CYONSFN2162, CYONSFN2010-BFXC, CYONSCN2024-BFXC, CYONSCN2028-BFXC, CYONSCN2020-BFXC, CYONSKN2033-BFXC, CYONSKN2035- BFXC, CYONSKN2030-BFXC, CYONSTN2040, CY8CTMA140, CY8C20xx7/7S, CY8C20045, CY8C20055, CYRF89x35, CY8C20065, CY8C24x93, CY7C69xxx 0 0 0 0 1 0 Features and Overview Provides a global shadow register for a selected port data register Generates a set of macros for port pin manipulation Prevents corruption of GPIO pin settings during CPU control of GPIO Cooperates with other user modules that allocate shadow registers. The ShadowRegs User Module creates a RAM variable (the shadow register) that caches values written to a port data register (PRTxDR). Using a shadow register enables CPU control of an individual GPIO output pin without the risk of corrupting the settings of other GPIO pins sharing the same port. Figure 1. ShadowRegs Block Diagram Cypress Semiconductor Corporation 198 Champion Court San Jose, CA 95134-1709 408-943-2600 Document Number: 001-16962 Rev. *H Revised May 21, 2013

Functional Description The ShadowRegs User Module creates a shadow register for the selected port data register. Note Some other user modules create shadow registers. If the selected port data register coincides with a port data register for which another user module created a shadow register, the user modules cooperate so that there is only one shadow register that needs to be accessed by your code. Theory of Operation Data written to a port data register may differ from data read from the port data register because the read data represents actual pin voltages while the written data controls the pin output setting (transistor switching). This difference between the read and write data introduces the risk of inadvertently corrupting a pin's output setting when performing a logical operation directly on the port data register to affect the setting of a different pin sharing the same port. This situation commonly occurs with pins operating in resistively pulled up/pulled down, or open drain drive modes. Data from a shadow register does not immediately write to a physical port. An ISR reflects the incorrect physical port values if this ISR calls before writing to the physical port but after updating shadow register. This happens because the physical port is not updated. It is recommended to disable interrupts before writing to a shadow register and enable interrupts only after writing data to a physical port. Example An application uses P0[0] as a sourcing LED output and P0[1] as a pulled up input for a normally open switch connected to ground. After setting the drive mode registers for port 0, the firmware initializes the LED to off and enables the input with the following C statement. PRT0DR = 0x02 Without a shadow, register, the firmware toggles the LED by the following C statement. PRT0DR ^= 0x01 On the initial LED toggle operation, the value read from PRT0DR is 0x00 if the switch is closed, and 0x02 if the switch is open. Performing the XOR operation to toggle the LED results in 0x01 (0x00 XOR 0x01) if the switch is closed but 0x03 (0x02 XOR 0x01) if the switch is open when the initial toggle occurs. Toggling the LED when the switch is closed causes P0[1] to be driven to 0 V internally. When the switch is opened, the value read from PRT0DR is still 0x01 because the voltage on P0[1] is still 0 V. The switch input was inadvertently disabled. The solution is to always manipulate the shadow register first, then copy the shadow register value into the port data register. The following C statements initialize the LED output and the switch input: Disable interrupts by clearing corresponding bits in the INT_MSKx registers Port_0_Data_SHADE = 0x02 PRT0DR = Port_0_Data_SHADE Enable interrupts by setting the corresponding bits in the INT_MSKx registers The following code toggles the LED without affecting the switch input Disable interrupts by clearing corresponding bits in the INT_MSKx registers Port_0_Data_SHADE ^= 0x01 PRT0DR = Port_0_Data_SHADE Enable interrupts by setting the corresponding bits in the INT_MSKx registers Document Number: 001-16962 Rev. *H Page 2 of 6

Regardless of whether the switch is open or closed, 0x03 (0x02 XOR 0x01) is written to the port data register on the initial toggle operation. This is because the logical operation is performed using the shadow register (0x02 regardless of whether the button is open or closed) as input rather than the port data register (0x00 when the switch is closed, and 0x02 when the switch is open). Interrupts are disabled or enabled to avoid incorrect ISR execution when the ISR calls after writing data to a shadow register, but before writing data to a physical port. Placement The ShadowRegs User Module is software only and does not consume any PSoC blocks. Multiple ShadowRegs User Modules can be used as necessary. Parameters and Resources ShadowPort This parameter selects the PRTxDR register for which a shadow register is created. The ShadowPort parameter contains a list of all available ports. Application Programming Interface There is no API for this user module. PSoC Designer generates pin manipulation macros for all named pins of the selected port. The pin manipulation macros are contained in the psocgpioint.inc file. It contains the following macros (ShadowRegs is replaced by the instance name of the user module): macro GetShadowRegsPin_Data macro SetShadowRegsPin_Data macro ClearShadowRegsPin_Data PSoC Designer automatically generates C language constants and masks in psocgpioint.h, but you need to create: MyPin_DataShadow &= ~MyPin_MASK MyPin_Data_ADDR = MyPin_DataShadow Sample Firmware Source Code The following is the Sample C code for this user module: This sample shows how to creates a shadow register for the Port_0 data register. The Port_0_Data_SHADE variable is defined in PSoCConfig.asm file as 'extern'. OVERVIEW: The SHADOWREGS UM creates a shadow register for the selected port data register. In this example the SHADOWREGS creates a shadow register for the Port_0 data register. The following changes need to be made to the default settings in the Device Editor: 1. Select SHADOWREGS user module. 2. Rename User Module's instance name to SHADOWREGS. Document Number: 001-16962 Rev. *H Page 3 of 6

3. Set User Module's ShadowPort Parameter to Port_0. CONFIGURATION DETAILS: 1. The UM's instance name must be shortened to SHADOWREGS. PROJECT SETTINGS: Default USER MODULE PARAMETER SETTINGS: ------------------------------------------------------------------------------- UM Parameter Value Comments ------------------------------------------------------------------------------- SHADOWREGS Name SHADOWREGS UM's instance name ShadowPort Port_0 ------------------------------------------------------------------------------- /* Code begins here */ #include <m8c.h> #include "PSoCAPI.h" part specific constants and macros PSoC API definitions for all User Modules void main(void) M8C_EnableGInt Uncomment this line to enable Global Interrupts Port_0_Data_SHADE = 0x00 while(1) if(prt0dr & 0x02) Port_0_Data_SHADE = 0x01 PRT0DR = Port_0_Data_SHADE else Port_0_Data_SHADE &= ~0x01 PRT0DR = Port_0_Data_SHADE Insert your main routine code here. Here is the same code in Assembly: This sample shows how to creates a shadow register for the Port_0 data register. The Port_0_Data_SHADE variable is defined in PSoCConfig.asm file as 'extern'. OVERVIEW: The SHADOWREGS UM creates a shadow register for the selected port data register. In this example the SHADOWREGS creates a shadow register for the Port_0 data register. Document Number: 001-16962 Rev. *H Page 4 of 6

The following changes need to be made to the default settings in the Device Editor: 1. Select SHADOWREGS user module. 2. Rename User Module's instance name to SHADOWREGS. 3. Set User Module's ShadowPort Parameter to Port_0. CONFIGURATION DETAILS: 1. The UM's instance name must be shortened to SHADOWREGS. PROJECT SETTINGS: Default USER MODULE PARAMETER SETTINGS: ------------------------------------------------------------------------------- UM Parameter Value Comments ------------------------------------------------------------------------------- SHADOWREGS Name SHADOWREGS UM's instance name ShadowPort Port_0 ------------------------------------------------------------------------------- Code begins here include "m8c.inc" include "memory.inc" include "PSoCAPI.inc" part specific constants and macros Constants & macros for SMM/LMM and Compiler PSoC API definitions for all User Modules export _main _main: M8C_EnableGInt Uncomment this line to enable Global Interrupts mov [Port_0_Data_SHADE], 0x00 Insert your main assembly code here..terminate: and reg[prt0dr], 0x02 jz.piniszero or [Port_0_Data_SHADE], 0x01 mov A, [Port_0_Data_SHADE] mov reg[prt0dr], A jmp.terminate.piniszero: and [Port_0_Data_SHADE], ~0x01 mov A, [Port_0_Data_SHADE] mov reg[prt0dr], A jmp.terminate Document Number: 001-16962 Rev. *H Page 5 of 6

Version History Version Originator Description 1.1 DHA Added Version History 1.1.b DHA Updated description for interrupt service routines in user module datasheet. Note PSoC Designer 5.1 introduces a Version History in all user module datasheets. This section documents high level descriptions of the differences between the current and previous user module versions. Document Number: 001-16962 Rev. *H Revised May 21, 2013 Page 6 of 6 Copyright 2007-2013 Cypress Semiconductor Corporation. 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. PSoC Designer and Programmable System-on-Chip are trademarks and PSoC is a registered trademark of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are property of the respective corporations. Any 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.