AN432 STMICROELECTRONICS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 12
Technical content
Rev. 1.1 AN432 APPLICATION NOTE USING ST62xx I/O PORTS SAFEL Y by J.Stockinger INTRODUCTION All members of the ST62 Series of Microcontrollers from STMicroelectronics feature I/O ports with configurable bit functions. In addition many I/O bits may be set as inputs to the on-chip Analog to Digital Converter. This port bit function is in addition to the normal I/O functions of input (with or without internal pull-up resistor), output (open drain or push-pull) or edge/level selectable interrupt input (with pull-up). This flexibility makes the ST62 series suitable for many industrial control applications (and for many other uses). This application note explains the architecture of the I/O bit associated with these port func- tions and provides some indications on the correct use of these features for functions such as keyboard scanning and analog inputs. The correct manner to switch between these function is also demonstrated in order to prevent potential malfunctions in operation.
1 I/O PORT STRUCTURE
capability are identical with the exception of the analog input buffer and control logic. Figure 1. ST62XX I/O port structure with A/D input tasheets for the specific addresses for the I/O ports with analog capability.
Table 1. Input and output modes of an I/O cell – reading the state of the I/O pin. quent read accesses to DR will return the content of the DR. Figure 2. D ata register access Figure 3. R ead multiplexing
USING ST62xx I/O PORTS SAFELY If the DDR bit corresponding to the I/O pin contains a “0", the port pin is set to input. Subse- quent read accesses to DR will return the state of the I/O pin. This means that the DR bit is ef- fectively Read Only when the bit is in Output mode. To read the content of any DR bit set to input mode a copy of the DR content previously written must be saved in Data RAM. Writing to the DR bit is possible in both input and output modes. It is important to note this as in input mode, DR is used to set the input pin characteristics (table 1). Due to the flexibility of programming each I/O bit individually, some pins of a port may be configured to input mode and others to output mode. Reading the DR will return some DR bit contents (from pins in output mode) and some I/O pin states (from pins in input mode) combined in the one byte. As will be shown in a following section this can create serious system malfunctions if care is not taken.
2 I/O PIN OPTIONS
Figure 4. I/O port with pins in different functions rupt inputs, pin 6 is analog input and pin 7 is an input without pull-up.
get a high signal at the core interrupt line ALL interrupt inputs must be high. Figure 5. Interrupt schematic for one I/O pin
3 OPERATION OF SINGLE BIT INSTRUCTIONS
The ST62XX instruction set includes four different instructions operating on single bits. The first two instructions use a read-modify-write cycle. the case of SET and RES, write the result back to the source. constraints in using these instructions with the Data Register. Table 2. Example for the operation of a single bit instruction As an example, let us assume that one or more of the pins of the port are set to input mode. result then written to DR as shown in Table 3.
Table 3. Example of a SET sequence with RAM buffer for DR tions apply for operating on OR or DDR.
4 MODE TRANSITION DIAGRAMS
Figure 6. shows the recommended transfer sequence for changing from one state to another (no other transitions should be used). Figure 6. Diagram for safe transitions Figure 7. illustrates the transitions which are most likely to cause a change of operation mode gether via the analog input line.
Figure 8. Diagram for I/O data register False transitions
USING ST62xx I/O PORTS SAFELY “THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH A NOTE AND/OR THE USE MADE BY CUSTOMERS OF THE INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.” Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners © 2003 STMicroelectronics - All rights reserved STMicroelectronics GROUP OF COMPANIES Australia – Belgium - Brazil - Canada - China – Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States