166KB

The following document contains information on Cypress products.
Colophon
The products described in this document are designed, developed and manufactured as contemplated for general use,
including without limitation, ordinary industrial use, general office use, personal use, and household use, but are not
designed, developed and manufactured as contemplated (1) for any use that includes fatal risks or dangers that, unless
extremely high safety is secured, could have a serious effect to the public, and could lead directly to death, personal injury,
severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic control,
mass transport control, medical life support system, missile launch control in weapon system), or (2) for any use where
chance of failure is intolerable (i.e., submersible repeater and artificial satellite). Please note that Spansion will not be liable
to you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products.
Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss from such
failures by incorporating safety design measures into your facility and equipment such as redundancy, fire protection, and
prevention of over-current levels and other abnormal operating conditions. If any products described in this document
represent goods or technologies subject to certain restrictions on export under the Foreign Exchange and Foreign Trade Law
of Japan, the US Export Administration Regulations or the applicable laws of any other country, the prior authorization by the
respective government entity will be required for export of those products.
Trademarks and Notice
The contents of this document are subject to change without notice. This document may contain information on a Spansion
product under development by Spansion. Spansion reserves the right to change or discontinue work on any product without
notice. The information in this document is provided as is without warranty or guarantee of any kind as to its accuracy,
completeness, operability, fitness for particular purpose, merchantability, non-infringement of third-party rights, or any other
warranty, express, implied, or statutory. Spansion assumes no liability for any damages of any kind arising out of the use of
the information in this document.
®
®
®
TM
Copyright © 2013 Spansion Inc. All rights reserved. Spansion , the Spansion logo, MirrorBit , MirrorBit Eclipse ,
TM
ORNAND and combinations thereof, are trademarks and registered trademarks of Spansion LLC in the United States and
other countries. Other names used are for informational purposes only and may be trademarks of their respective owners.
Fujitsu Semiconductor (Shanghai) Co., Ltd.
Application Note
MCU-AN- 500024-E-11
F²MC-8FX FAMILY
8-BIT MICROCONTROLLER
MB95200 SERIES
I/O API USAGE
APPLICATION NOTE
I/O API Usage V1.1
Revision History
Revision History
Date
2009-3-3
2009-3-5
Author
Jane, Li
Jane, Li
Change of Records
V1.0, First draft
V1.1, Add code to function
This manual contains 16 pages.
1. The products described in this manual and the specifications thereof may be changed without prior notice.
To obtain up-to-date information and/or specifications, contact your Fujitsu sales representative or Fujitsu
authorized dealer.
2. Fujitsu will not be liable for infringement of copyright, industrial property right, or other rights of a third party
caused by the use of information or drawings described in this manual.
3. The contents of this manual may not be transferred or copied without the express permission of Fujitsu.
4. The products contained in this manual are not intended for use with equipments which require extremely
high reliability such as aerospace equipments, undersea repeaters, nuclear control systems or medical
equipments for life support.
5. Some of the products described in this manual may be strategic materials (or special technology) as defined
by the Foreign Exchange and Foreign Trade Control Law. In such cases, the products or portions thereof
must not be exported without permission as defined under the law.
© 2009 Fujitsu Semiconductor (Shanghai) Co., Ltd.
MCU-AN- 500024-E-11 – Page 2
I/O API Usage V1.1
CONTENTS
CONTENTS
REVISION HISTORY .............................................................................................................. 2 1 INTRODUCTION ................................................................................................................ 4 2 I/O PORTS LIBRARY FUNCTION LIST ............................................................................ 5 3 I/O PORTS FUNCTION DETAIL ........................................................................................ 6 3.1 IO_Input Function...................................................................................................... 6 3.2 IO_Output Function ................................................................................................... 7 3.3 IO_Pull_Up Function ................................................................................................. 7 3.4 IO_Direction Function ............................................................................................... 8 3.5 IO_AD_Select Function............................................................................................. 9 3.6 Especial_IO Function ................................................................................................ 9 4 USAGE DEMO ................................................................................................................. 11 4.1 Digital Port Input or Peripheral Function Input ........................................................ 11 4.2 Digital Port Output ................................................................................................... 11 4.3 Pull Up Register Usage ........................................................................................... 11 4.4 AD Input Allowed..................................................................................................... 11 4.5 Especial_IO Usage ................................................................................................. 11 5 CODE OF FUNCTION ..................................................................................................... 12 5.1 IO_Input Code ......................................................................................................... 12 5.2 IO_Output Code ...................................................................................................... 13 5.3 IO_Pull_Up Code .................................................................................................... 13 5.4 IO_Direction Code................................................................................................... 13 5.5 IO_AD_Select Code ................................................................................................ 13 5.6 Especial_IO Code ................................................................................................... 13 6 ADDITIONAL INFORMATION ......................................................................................... 15 7 APPENDIX ....................................................................................................................... 16 7.1 Tables ..................................................................................................................... 16 MCU-AN- 500024-E-11 – Page 3
I/O API Usage V1.1
Chapter 1 Introduction
1 Introduction
This document introduces API for IO ports.
We should set up four functions to control IO port: IO input mode, IO output mode, IO pull up
and IO direction.
MCU-AN- 500024-E-11 – Page 4
I/O API Usage V1.1
Chapter 2 I/O Ports Library Function List
2 I/O Ports Library Function List
This chapter introduces the I/O port library all functions.
Table 2-1 lists the I/O Ports library functions.
Table 2- 1 I/O Ports Functions
Function name
Description
void IO_Input(uint IO_Data_Port, uchar IO_Pin)
Setting the IO ports as input and choose the
port optionally.
void IO_Output(uint IO_Data_Port, uchar IO_Pin, uchar
Out_Value)
Setting the IO ports as output and choose the
port optionally.
void IO_Pull_Up(uchar PU_Port, uchar IO_Pin, uchar
IO_PU_Status)
The P0 and PG ports, enable/disable the pullup register.
void IO_Direction(uchar PD_Port, uchar IO_Pin, uchar
Direction)
Setting the direction for each channel.
void IO_AD_Select(uint AD_IO,uchar IO_Pin,uchar AD_Status)
Select Port0 as GPIO or AD function.
void Especial_IO(uint Spec_IO, uchar Function_IOPin, uchar
Function)
Select Port F, Port G as GPIO or other
function.
MCU-AN- 500024-E-11 – Page 5
I/O API Usage V1.1
Chapter 3 I/O Ports Function Detail
3 I/O Ports Function Detail
This chapter introduces the detail of I/O Ports function.
3.1
IO_Input Function
IO_Input(Input parameter1, Input parameter2);
Table 3-1 describes IO_Input function.
Function name
Function prototype
Behavior description
Table 3- 1 IO_Input Function
IO_Input
void IO_Input(uint IO_Data_Port, uchar IO_Pin)
Set IO input pin
Input parameter1
IO_Data_Port
Input parameter2
IO_Pin, choose operation pin
Return value
None
Select the IO port as input pins. In this parameter user can choose more than one of the IO
pins as IO input pins, and get the external circuit value.
Table 3-2 describes the IO_Data_Port parameter values.
IO_Data_Port
Table 3- 2 IO_Data_Port Definition
Description
Data_ Port0
Set port 0
Data_ Port1
Set port 1
Data_ Port6
Set port 6
Data_ Port F
Set port F
Data_ Port G
Set port G
Table 3-3 describes the IO_Pin parameter values.
IO_Pin
Table 3- 3 IO_Pin Definition
Description
P0
First Pin in each Port
P1
Second pin in each port
P2
Third pin in each port
P3
Forth pin in each port
P4
Fifth pin in each port
P5
Sixth pin in each port
P6
Seventh pin in each port
P7
Eighth pin in each port
ALL
All Pins in each Port
MCU-AN- 500024-E-11 – Page 6
I/O API Usage V1.1
Chapter 3 I/O Ports Function Detail
3.2
IO_Output Function
IO_Output(Input parameter1, Input parameter2, Input parameter3);
Table 3-4 describes IO_Output function.
Function name
Table 3- 4 IO_Output Function
IO_Output
Function prototype
void IO_Output(uint IO_Data_Port, uchar IO_Pin,uchar Out_Value)
Behavior description
Control the IO output pin and values
Input parameter1
IO_Data_Port, Refer to table 3-2 for more details on the allowed values for
this parameter.
Input parameter2
Input parameter3
IO_Pin, Choose operation pin.
Refer to table 3-3 for more details on the allowed values for this
parameter.
Out_Value, Setting the output value for single pin
Return value
None
Select the IO port as output pins. In this parameter user can choose more than one of the IO
pins as output pins and pass the control signal to the external circuit.
Table 3-5 describes the Out_Value parameter values.
Out_Value
Table 3- 5 Out _ Value Definition
Description
Out_L
out value 0
Out_H
out value 1
3.3
IO_Pull_Up Function
IO_Pull_up(Input parameter1, Input parameter2, Input parameter3);
Table 3-6 describes IO_Output function.
Function name
Table 3- 6 IO_Output Function
IO_Pull_Up
Function prototype
void IO_Pull_Up(uchar PU_Port,uchar IO_Pin,uchar IO_PU_Status)
Behavior description
The P0 and PG ports, enable/disable the pull-up register.
Input parameter1
PU_Port, Setting the Pull-Up port
Input parameter2
IO_Pin, Choose operation pin
Refer to table 3-3 for more details on the allowed values for this parameter.
IO_PU_Status, only have two values: IO_PU_Enable and IO_PU_Disable,
Setting the pull-up for single pin
Input parameter3
Return value
None
Enable or disable the pull up register. This function can only used in port 0 and port G.
MCU-AN- 500024-E-11 – Page 7
I/O API Usage V1.1
Chapter 3 I/O Ports Function Detail
Table 3-7 describes the PU_Port parameter values.
Table 3- 7 PU_Port Definition
Description
PU_Port
Pull_Up_Port0
Port0
Pull_Up_PortG
PortG
3.4
IO_Direction Function
IO_Direction(Input parameter1, Input parameter2, Input parameter3);
Table 3-8 describes IO_Direction function.
Function name
Table 3- 8 IO_Direction Function
IO_Direction
Function prototype
void IO_Direction(uchar PD_Port, uchar IO_Pin, uchar Direction)
Behavior description
decide the pins as input pins or output pins
Input parameter1
PD_Port
Input parameter2
Input parameter3
IO_Pin, Choose operation pin
Refer to table 3-3 for more details on the allowed values for this
parameter.
Direction, only have two values: Direction_In and Direction_Out
Return value
None
Table 3-9 describes the PD_Port parameter values.
PD_Port
Table 3- 9 PD_Port Definition
Description
Direction_Port0
Port0
Direction_Port1
Port1
Direction_Port6
Port6
Direction_PortF
PortF
Direction_PortG
PortG
MCU-AN- 500024-E-11 – Page 8
I/O API Usage V1.1
Chapter 3 I/O Ports Function Detail
3.5
IO_AD_Select Function
IO_AD_Select(Input parameter1, Input parameter2, Input parameter3);
Table 3-10 describes IO_AD_Select function.
Table 3- 10 IO_AD_Select Function
IO_AD_Select
Function name
Function prototype
void IO_AD_Select(uint AD_IO,uchar IO_Pin,uchar AD_Status)
Behavior description
Set IO pin used as AD function pin
Input parameter1
AD_IO, only have one value: AD_IO_Port0
Input parameter2
Input parameter3
IO_Pin, Choose operation pin.
Refer to table 3-3 for more details on the allowed values for this parameter.
AD_Status, only have two values: AD_Enable and AD_Disable
Return value
None
3.6
Especial_IO Function
Especial_IO(Input parameter1, Input parameter2, Input parameter3);
Table 3-11 describes Especial_IO function.
Table 3- 11 Especial_IO Function
Function name
Especial_IO
Function prototype
void Especial_IO(uint Espec_IO, uchar Function_IOPin, uchar Function)
Behavior description
Set IO used as especial function IO
Input parameter1
Espec_IO, only have one values: Function_IO
Input parameter2
Function_IOPin
Input parameter3
Function, values be relate to Function_IOPin parameter.
For example: when Function_PF0, the Function only have two input
values: IO_PF0 and MainC_PF0.
None
Return value
Table 3-12 describes the Function_IOPin parameter values.
Function_IOPin
Table 3- 12 Function_IOPin Definition
Description
Function_PF0
PF0
Function_PF1
PF1
Function_PF2
PF2
Function_PG1
PG1
Function_PG2
PG2
MCU-AN- 500024-E-11 – Page 9
I/O API Usage V1.1
Chapter 3 I/O Ports Function Detail
Table 3-13 describes the Function parameter values.
Function
Table 3- 13 Function Definition
Description
IO_PF0
IO function
MainC_PF0
Especial Function
IO_PF1
IO function
MainC_PF1
Especial Function
IO_PF2
IO function
RSTX_PF2
Especial Function
IO_PG1
IO function
SubC_PG1
Especial Function
IO_PG2
IO function
SubC_PG2
Especial Function
MCU-AN- 500024-E-11 – Page 10
I/O API Usage V1.1
Chapter 4 Usage Demo
4 Usage Demo
This chapter is some demo which introduces how to use these I/O Ports.
4.1
Digital Port Input or Peripheral Function Input
This can be done by calling the following functions successively using appropriate
parameters.
4.2
IO_Direction(Direction_Port0,P0, Direction_In);
//port 0 as input pin
IO_Input(Data_Port0,P0);
//port 0,bit0
Digital Port Output
IO_Direction(Direction_Port0,P0,Direction_Out);
IO_Output(Data_Port0,P0,Out_H);
4.3
//port 0 as output pin
//port 0,bit 0, output value 1
Pull Up Register Usage
This example shows that how to use the pull up register. note that there are only port
0 and port G have pull up register, and also only if the port as input pin could use pull up
register.
4.4
IO_Direction(Direction_Port0,P0,Direction_In);
//port 0 as input pin
IO_Pull_up(Pull_Up_Port0, P0, Pull_Up_Enable);
/P00 use the pull up register
IO_Input(Data_Port0,P0);
//port 0,bit0
AD Input Allowed
IO_AD_Select(AD_IO_Port0,P0, AD_Enable);
4.5
//AD Input enable.
Especial_IO Usage
Especial_IO(Function_IO, Function_PF0, IO_PF0); //PF0 as IO port
MCU-AN- 500024-E-11 – Page 11
I/O API Usage V1.1
Chapter 5 Code of function
5 Code of function
This chapter list all function’s code.
5.1
IO_Input Code
IO_InPin:
PUSHW
MOVW
MOVW
MOV
PUSHW
MOV
PUSHW
MOV
PUSHW
IX
A,SP
IX,A
A,R0
A
A,R1
A
A,R2
A
MOV
CMP
BZ
MOV
MOVW
MOV
BIT_SHIFT:
CMP
BZ
CLRC
RORC
DEC
JMP
KEEP_BIT0:
AND
MOVW
JMP
In_ALL:
MOVW
MOV
MOVW
JMP
A,@IX+07H
A,#0x08
In_ALL
R0,A
A,@IX+04H
A,@A
R0,#0
KEEP_BIT0
A
R0
BIT_SHIFT
A,#01
EP,A
RESUME
A,@IX+04H
A,@A
EP,A
RESUME
MCU-AN- 500024-E-11 – Page 12
I/O API Usage V1.1
Chapter 5 Code of function
5.2
IO_Output Code
5.3
IO_Pull_Up Code
5.4
IO_Direction Code
5.5
IO_AD_Select Code
5.6
Especial_IO Code
MCU-AN- 500024-E-11 – Page 13
I/O API Usage V1.1
Chapter 5 Code of function
_IO_Output:
_IO_Pull_Up:
_IO_Direction:
_IO_AD_Select:
_Especial_IO:
PUSHW IX
MOVW
A,SP
MOVW
IX,A
MOV
A,R0
PUSHW A
MOV
A,R1
PUSHW A
MOV
A,R2
PUSHW A
;-----------------------------------------------------------------------------IO_Pin:
MOV
A,@IX+07H
CMP
A,#0x08
BZ
ALL_Init
MOV
R0,A
MOV
A,@IX+09H
MOV
R1,A
MOV
R2,#0xFE
BIT_shift:
;Shift bit operation
CMP
R0,#0
BZ
CHANGE_BIT
MOV
A,R1
CLRC
ROLC
A
MOV
R1,A
MOV
A,R2
SETC
ROLC
A
MOV
R2,A
DEC
R0
JMP
BIT_shift
CHANGE_BIT:
;Change corresponding bit
MOVW
A,@IX+04H
MOVW
EP,A
MOV
A,@A
AND
A,R2
OR
A,R1
MOV
@EP,A
JMP
RESUME
ALL_Init:
MOVW
MOVW
MOV
MOV
MOV
RESUME:
POPW
MOV
POPW
MOV
POPW
MOV
POPW
RET
;If select all pins, operation here
A,@IX+04H
EP,A
A,@A
A,@IX+09H
@EP,A
A
R2,A
A
R1,A
A
R0,A
IX
MCU-AN- 500024-E-11 – Page 14
I/O API Usage V1.1
Chapter 6 Additional Information
6 Additional Information
For more information about how to use MB95200H EV-board, BGM Adaptor and SOFTUNE,
please refer to SKT MB2146-410-01-E User Manual, or visit websites:
English version:
http://www.fujitsu.com/cn/fsp/services/mcu/mb95/application_notes.html
Simplified Chinese Version:
http://www.fujitsu.com/cn/fss/services/mcu/mb95/application_notes.html
MCU-AN- 500024-E-11 – Page 15
I/O API Usage V1.1
Chapter 7 Appendix
7 Appendix
7.1
Tables
Table 2- 1 I/O Ports Functions ................................................................................................. 5
Table 3- 1 IO_Input Function ................................................................................................... 6 Table 3- 2 IO_Data_Port Definition .......................................................................................... 6 Table 3- 3 IO_Pin Definition ..................................................................................................... 6 Table 3- 4 IO_Output Function ................................................................................................ 7 Table 3- 5 Out _ Value Definition ............................................................................................. 7 Table 3- 6 IO_Output Function ................................................................................................ 7 Table 3- 7 PU_Port Definition .................................................................................................. 8 Table 3- 8 IO_Direction Function ............................................................................................. 8 Table 3- 9 PD_Port Definition .................................................................................................. 8 Table 3- 10 IO_AD_Select Function ........................................................................................ 9 Table 3- 11 Especial_IO Function ............................................................................................ 9 Table 3- 12 Function_IOPin Definition ..................................................................................... 9 Table 3- 13 Function Definition .............................................................................................. 10 MCU-AN- 500024-E-11 – Page 16