240KB

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- 500022-E-10
F²MC-8FX FAMILY
8-BIT MICROCONTROLLER
MB95200 SERIES
BASIC API
APPLICATION NOTE
Basic API V1.0
Revision History
Revision History
Date
2009-3-13
Author
Jane, Li
Change of Records
V1.0, First draft
This manual contains 32 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.
© 2008 Fujitsu Semiconductor (Shanghai) Co., Ltd.
MCU-AN- 500022-E-10 – Page 2
Basic API V1.0
CONTENTS
CONTENTS
REVISION HISTORY .............................................................................................................. 2 1 INTRODUCTION ................................................................................................................ 5 2 CLOCK CONTROLLER..................................................................................................... 6 2.1 Clock Controller Library Function List ....................................................................... 6 2.2 Clock Library Function Detail .................................................................................... 6 2.2.1 Clock_Set_CPU_Clock Function ................................................................ 6 2.2.2 Clock_Get_CPU_Clock_Status Function .................................................... 7 2.2.3 Clock_Set_Divide Function ......................................................................... 7 2.2.4 Clock_Get_Divide_Status Function ............................................................ 8 2.2.5 Oscl_Stabilization_Time_Set Function ....................................................... 8 2.3 Usage Demo ........................................................................................................... 10 2.3.1 Clock Control............................................................................................. 10 2.3.2 Get Clock status ........................................................................................ 10 3 CLOCK SUPERVISOR COUNTER ................................................................................. 11 3.1 Clock Supervisor Counter Function List .................................................................. 11 3.2 Clock Supervisor Counter Function Detail .............................................................. 11 3.2.1 Clock_Supervisor_Counter Function ........................................................ 11 3.3 Usage Demo ........................................................................................................... 12 3.3.1 Start........................................................................................................... 12 3.3.2 Get the Result of Check ............................................................................ 12 4 STANDBY MODE ............................................................................................................ 13 4.1 Standby Mode Library Function List........................................................................ 13 4.2 Standby Mode Function Detail ................................................................................ 13 4.2.1 Standby_Mode_Enter Function ................................................................. 13 4.2.2 Mode_Pin_State Function ......................................................................... 14 4.2.3 Software_Reset Function .......................................................................... 14 4.3 Usage Demo ........................................................................................................... 15 4.3.1 Set Standby Mode and Software Reset .................................................... 15 5 WILD REGISTER FUNCTION ......................................................................................... 16 5.1 Wild Register Library Function List ......................................................................... 16 5.2 Wild Register Function Detail .................................................................................. 16 5.2.1 Wild_Register_Init Function ...................................................................... 16 5.2.2 Wild_Register_Read ................................................................................. 17 5.2.3 Wild_Register_Status ................................................................................ 17 MCU-AN- 500022-E-10 – Page 3
Basic API V1.0
CONTENTS
5.3 Usage Demo ........................................................................................................... 18 5.3.1 Modified Data ............................................................................................ 18 5.3.2 Wild Register Disable Work ...................................................................... 18 5.3.3 Read Wild Register ................................................................................... 18 6 INTERRUPTS .................................................................................................................. 20 6.1 Interrupts Library Function List................................................................................ 21 6.2 Interrupts Function Detail ........................................................................................ 22 6.2.1 External_Interrupt Function ....................................................................... 22 6.2.2 External_Interrupt_Level Function ............................................................ 23 6.2.3 External_Interrupt_Request Function ....................................................... 24 6.2.4 Other Interrupt Control Function ............................................................... 24 6.2.5 Other Interrupt Level Function .................................................................. 25 6.2.6 Other Clear and Get Interrupt Request Function ...................................... 26 6.3 Usage Demo ........................................................................................................... 26 6.3.1 External Interrupt....................................................................................... 26 6.3.2 Other Interrupt ........................................................................................... 26 7 EXTERNAL INTERRUPT ................................................................................................ 28 7.1 External Interrupt Library Function List ................................................................... 28 7.2 External Interrupt Function Detail............................................................................ 28 7.2.1 External_Interrupt_Init function ................................................................. 28 7.3 Usage Demo ........................................................................................................... 29 8 ADDITIONAL INFORMATION ......................................................................................... 30 9 APPENDIX ....................................................................................................................... 31 9.1 Tables ..................................................................................................................... 31 MCU-AN- 500022-E-10 – Page 4
Basic API V1.0
Chapter 1 Introduction
1 Introduction
This document introduces API for Clock, CSV, Standby mode, Wilder register, Interrupt and
External Interrupt.
MCU-AN- 500022-E-10 – Page 5
Basic API V1.0
Chapter 2 Clock Controller
2 Clock Controller
The clock library has five functions to realize control clock, including setting clock, getting
clock, dividing status, setting clock divide and setting oscillator stabilization time.
2.1
Clock Controller Library Function List
Table 2-1 lists the Clock library functions.
Table 2- 1 Clock Library Functions
Function name
Description
void Clock_Set_CPU_Clock(uint CLOCK)
Set the machine clock
uchar Clock_Get_CPU_Clock_status(void)
Get the current clock status
void Clock_Set_Divide(uchar Clock_Div)
Set the machine clock divide
uchar Clock_Get_Divide_Status(void)
Get the current clock divide status
void Clock_Stabilization_Time_Set(uint CLOCK_TIME)
Set clock stabilization time
2.2
Clock Library Function Detail
2.2.1 Clock_Set_CPU_Clock Function
Table 2-2 describes Clock_Set_CPU_Clock function.
Function name
Table 2- 2 Clock_Set_CPU_Clock Function
Clock_Set_CPU_Clock
Function prototype
void Clock_Set_CPU_Clock(uint CLOCK)
Behavior description
Set the machine clock select parameter ‘clock’ to correct value and will set
the clock as MCU run clock.
Input parameter
CLOCK
Return value
None
For example:
If you want select main clock as MCU run clock, you can set the function:
Clock_Set_CPU_Clock(Main_Clock) and succeed.
Table 2-3 describes the Clock parameter values.
CLOCK
Table 2- 3 CLOCK Definition
Description
Main_Clock
Set main clock as machine clock
Sub_Clock
Set sub clock as machine clock
Main_CR_Clock
Set main CR clock as machine clock
Sub_CR_Clock
Set sub clock as machine clock
MCU-AN- 500022-E-10 – Page 6
Basic API V1.0
Chapter 2 Clock Controller
2.2.2 Clock_Get_CPU_Clock_Status Function
Table 2-4 describes Clock_Get_CPU_Clock_Status function.
Function name
Table 2- 4 Clock_Get_CPU_Clock_Status Function
Clock_Get_CPU_Clock_Status
Function prototype
uchar Clock_Get_CPU_Clock_status(void)
Behavior description
Get the run clock
Input parameter
None
Return value
Return value has four virtual values: 0x00(Sub_CR_clock),
0x01(Sub_clock), 0x02(main_CR_clock), 0x03(main_clock).
2.2.3 Clock_Set_Divide Function
Table 2-5 describes Clock_Set_Divide function.
Table 2- 5 Clock_Set_Divide Function
Function name
Clock_Set_Divide
Function prototype
void Clock_Set_Divide(uchar Clock_Div)
Behavior description
Set the machine clock divide
Input parameter
Clock_Div
Return value
None
This function can set the clock divide. Select parameter ‘Clock_Div’ to correct value and will
set the clock divide.
Table 2-6 describes the Clock_Div parameter values.
Clock_Div
Table 2- 6 Clock_Div Function
Description
Clock_Div_No
Set clock divide no as machine clock
Clock_Div_4
Set clock divide 4 as machine clock
Clock_Div_8
Set clock 8 as machine clock
Clock_Div_16
Set clock 16 as machine clock
MCU-AN- 500022-E-10 – Page 7
Basic API V1.0
Chapter 2 Clock Controller
2.2.4 Clock_Get_Divide_Status Function
Table 2-7 describes Clock_Get_Divide_Status function.
Function name
Table 2- 7 Clock_Get_Divide_Status Function
Clock_Get_Divide_Status
Function prototype
uchar Clock_Get_Divide_Status(void)
Behavior description
get the clock divide status
Input parameter
None
Return value
Return clock divide status, refer to table 2-6
The function can get the clock divide status. Select parameter ‘clock’ to correct value and will
get the clock divide status. The return value has four virtual values: Clock_Div_No,
Clock_Div_4, Clock_Div_8 and Clock_Div_16.
2.2.5 Oscl_Stabilization_Time_Set Function
Table 2-8 describes Oscl_Stabilization_Time_Set function.
Function name
Table 2- 8 Oscl_Clock_Stabilization_Time Function
Oscl_Stabilization_Time_Set
Function prototype
void Clock_Stabilization_Time_Set( uint CLOCK_TIME)
Behavior description
Set clock stabilization wait time
Input parameter
CLOCK_TIME
Return value
None
The function can set the clock stabilization wait time. Select parameter CLOCK_TIME to
correct value and will set the clock stabilization wait time.
MCU-AN- 500022-E-10 – Page 8
Basic API V1.0
Chapter 2 Clock Controller
Table 2-9 describes CLOCK_TIME parameter definition.
Table 2- 9 CLOCK_TIME Definition
CLOCK_TIME
Description
FCH_14_DIV
(214-2)/FCH
FCH_13_DIV
(213-2)/FCH
FCH_12_DIV
(212-2)/FCH
FCH_11_DIV
(211-2)/FCH
FCH_10_DIV
(210-2)/FCH
FCH_9_DIV
(29-2)/FCH
FCH_8_DIV
(28-2)/FCH
FCH_7_DIV
(27-2)/FCH
FCH_6_DIV
(26-2)/FCH
FCH_5_DIV
(25-2)/FCH
FCH_4_DIV
(24-2)/FCH
FCH_3_DIV
(23-2)/FCH
FCH_2_DIV
(22-2)/FCH
FCH_1_DIV
(21-2)/FCH
FCL _15_DIV
(215-2)/FCL
FCL_14_DIV
(214-2)/FCL
FCL_13_DIV
(213-2)/FCL
FCL_12_DIV
(212-2)/FCL
FCL_11_DIV
(211-2)/FCL
FCL_10_DIV
(210-2)/FCL
FCL_9_DIV
(29-2)/FCL
FCL_8_DIV
(28-2)/FCL
FCL_7_DIV
(27-2)/FCL
FCL_6_DIV
(26-2)/FCL
FCL_5_DIV
(25-2)/FCL
FCL_4_DIV
(24-2)/FCL
FCL_3_DIV
(23-2)/FCL
FCL_2_DIV
(22-2)/FCL
FCL_1_DIV
(21-2)/FCL
MCU-AN- 500022-E-10 – Page 9
Basic API V1.0
Chapter 2 Clock Controller
2.3
Usage Demo
2.3.1 Clock Control
Control clock includes setting stabilization time, setting clock divide and setting clock mode.
Select clock has four values: main clock, sub clock, main CR clock, sub CR clock. The clock
stabilization time is changed by the CLOCK_TIME. First set the clock stabilization time,
second select what clock use as source clock and last set the clock divide.
For example, if you want set the main clock, select main clock mode and set the clock to
source/4, add the following function to you program.
//the sample code to control main clock
void clock_control(void)
{
Clock_Stabilization_Time_Set(FCH_14_DIV);
//set main clock stabilization time
Clock_Set_CPU_Clock(Main_Clock) ;
// set main clock
Clock_Set_Divide(Clock_Div_4);
// set the clock to source/4
}
2.3.2 Get Clock Status
When you want to know the clock mode and clock divide status, you can use uchar
Clock_Get_CPU_Clock_status(void) and uchar Clock_Get_Divide_Status(void) function.
The sample as:
Void get_clock_status(void)
{
uchar state,state1;
state = Clock_Get_CPU_Clock_status ();
//return run clock mode
state1 = Clock_Get_Divide_Status ();
//return the clock divide status
}
MCU-AN- 500022-E-10 – Page 10
Basic API V1.0
Chapter 3 Clock Supervisor Counter
3 Clock Supervisor Counter
This chapter introduces all functions of Clock library.
3.1
Clock Supervisor Counter Function List
Table 3-1 lists the Clock Supervisor Counter library functions.
Table 3- 1 Clock Supervisor Counter Function
Function name
Description
uchar Clock_Supervisor_Counter (uchar Mod,uint
EX_size)
3.2
Initialize the CSV and check the external clock
frequency.
Clock Supervisor Counter Function Detail
3.2.1 Clock_Supervisor_Counter Function
Table 3-2 describes the Clock_Supervisor_Counter function.
Table 3- 2 Clock_Supervisor_Counter Function
Clock_Supervisor_Counter
Function name
Function prototype
uchar Clock_Supervisor_Counter (uchar Mod,uint EX_size)
Behavior description
Initialize the CSV and check the external clock frequency
Input parameter1
Mod, Set the mode of check
Input parameter2
EX_size, get the size of external clock frequency
For example: external clock frequency is 1 MHz, EX_size = 1000
Return value
0, initialization is failing
1, external clock frequency is correct
2. external clock frequency is not correct
This function use to check external clock frequency. You must startup main CR clock
(SYCC2: MCRE=1, RCS=2) and enable main clock (SYSC: PFSEL=0; SYCC2: MOSCE=1)
or sub clock (SYSC: PGSEL=0; SYCC2: SOSCE=1) before use this function. You can set
the size of main CR clock (CRTH: CRSEL=0~3 <1 MHz, 10 MHz, 8 MHz>) to check external
clock frequency.
Table 3-3 describes the Mod parameter values.
Table 3- 3 Mod Definition
Mod
Description
Main_clock
Main clock
Sub_clock
Sub clock
MCU-AN- 500022-E-10 – Page 11
Basic API V1.0
Chapter 3 Clock Supervisor Counter
3.3
Usage Demo
3.3.1 Start
Initialize the Clock Supervisor Counter, set the mode to check main clock or sub clock
for your need, and input the external clock frequency to calculate the optimal interval time.
For example:
We should check the main clock, and the main clock frequency is 4 MHz, the operation
as following:
Clock_Supervisor_Counter (main_clock, 4000) or Clock_Supervisor_Counter (0x00, 4000).
3.3.2 Get the Result of Check
Clock_Supervisor_Counter () function can return the result of check, the value of return
is “0” or “1” or “2”, ”0” explain the parameter error, “1” explain the external clock frequency
isn’t correct, “2” explain the external clock frequency is correct.
MCU-AN- 500022-E-10 – Page 12
Basic API V1.0
Chapter 4 Standby Mode
4 Standby Mode
This chapter introduces all functions of standby library.
In routine, the standby mode library has three functions: Standby_Mode_Enter
(STANDBY_MODE), Mode_Pin_State(MODE_PIN_STATUS) and Software_Reset().This
function can realize transition from normal mode to other mode, such as stop mode, watch
mode.
4.1
Standby Mode Library Function List
Table 4-1 lists the Standby mode library functions.
Table 4- 1 Standby Mode Functions
Function name
Description
void Standby_Mode_Enter(uchar STANDBY_MODE)
Select standby mode
void Mode_Pin_State(uchar MODE_PIN_STATUS)
High_Impedance / Hold_Preceding
void Software_Reset(void)
Generates a 3-machine clock reset signal
4.2
Standby Mode Function Detail
4.2.1 Standby_Mode_Enter Function
Table 4-2 describes Standby_Mode_Enter function.
Function name
Table 4- 2 Standby_Mode_Enter Function
Standby_Mode_Enter
Function prototype
void Standby_Mode_Enter(uchar STANDBY_MODE)
Behavior description
realize transition from normal mode to other mode
Input parameter
STANDBY_MODE
Return value
None
Select parameter ‘STANDBY_MODE’ to correct value and it can realize transition from
normal mode to other mode, such as stop mode, watch mode. For example, if you want
MCU run in stop mode, you can set the function: Standby_Mode_Enter(Stop_Mode) and
succeed.
Table 4-3 describes the STANDBY_MODE parameter values.
STANDBY_MODE
Table 4- 3 STANDBY_MODE Definition
Description
Stop_Mode
Set standby mode to stop mode
Sleep_Mode
Set standby mode to sleep mode
Watch_mode
Set standby mode to watch mode
Timebase_timer_Mode
Set standby mode to Timebase timer mode
MCU-AN- 500022-E-10 – Page 13
Basic API V1.0
Chapter 4 Standby Mode
4.2.2 Mode_Pin_State Function
Table 4-4 describes Mode_Pin_State function.
Function name
Table 4- 4 Mode_Pin_State function
Mode_Pin_State
Function prototype
void Mode_Pin_State(uchar MODE_PIN_STATUS)
Behavior description
realize setting the pin state after enter one standby mode
Input parameter
MODE_PIN_STATUS, Pin state can select high impedance and hold
preceding status
Return value
None
Select parameter ‘MODE_PIN_STATUS’ to correct value and it can realize setting the pin
state after enter one standby mode. Pin state can select high impedance and hold preceding
status.
Table 4-5 describes the MODE_PIN_STATUS parameter values.
MODE_PIN_STATUS
Table 4- 5 MODE_PIN_STATUS Definition
Description
High_Impedance
places external pins in a high impedance state in stop mode, timebase
timer mode, or watch mode
Hold_Preceding
Holds external pins in their immediately preceding state in stop mode,
timebase timer mode, or watch mode
4.2.3 Software_Reset Function
Table 4-6 describes Software_Reset function.
Function name
Table 4- 6 Software_Reset Function
Software_Reset
Function prototype
void Software_Reset(void)
Behavior description
generates a 3-machine clock reset signal
Input parameter
None
Return value
None
The function can generates a 3-machine clock reset signal.
MCU-AN- 500022-E-10 – Page 14
Basic API V1.0
Chapter 4 Standby Mode
4.3
Usage Demo
4.3.1 Set Standby Mode and Software Reset
If you want to set the standby mode, just use Standby_Mode_Enter(STANDBY_MODE)
function. Select parameter ‘STANDBY_MODE’ to correct value and it can realize transition
from normal mode to other mode. Run software_reset(void) function can realize reset MCU.
The sample as:
If (change_to_stop_mode)
{
Mode_Pin_State(High_Impedance); // places external pins in a high impedance
Standby_Mode_Enter(Stop_Mode); //set stop mode
}
MCU-AN- 500022-E-10 – Page 15
Basic API V1.0
Chapter 5 Wild Register Function
5 Wild Register Function
This chapter introduces all functions of wild register library.
5.1
Wild Register Library Function List
Table 5-1 lists the wild register library functions.
Table 5- 1 Wild Register Functions
Function name
Description
void Wild_Register_Initial(uint Channel, uint Address, uchar
Data)
Select wild register operation channel,
modified address and data
void Wild_Register_Read (uint Channel,uchar Status)
Enable or disable read wild register
void Wild_Register_Status(uint Channel,uchar Status)
Enable or disable wild register work
5.2
Wild Register Function Detail
5.2.1 Wild_Register_Init Function
Table 5-2 describes Wild_Register_Initial function.
Function name
Table 5- 2 Wild_Register_Initial Function
Wild_Register_Initial
Function prototype
void Wild_Register_Initial(uint Channel,uint Address,uchar Data)
Behavior description
Select wild register operation channel, modified address and data
Input parameter1
Channel, Select operation wild register
Input parameter2
Address, Modified address
Input parameter3
Data, Modified data
Return value
None
The function select channel of the wild register, set modified address and modified data, and
then enables corresponding wild register address compare enable register (WREN).
Table 5-3 describes the Channel parameter values.
Channel
Table 5- 3 Channel Definition
Description
Wild_Channel_0
wild register 0
Wild_Channel_1
wild register 1
Wild_Channel_2
wild register 2
MCU-AN- 500022-E-10 – Page 16
Basic API V1.0
Chapter 5 Wild Register Function
5.2.2 Wild_Register_Read
Table 5-4 describes Wild_Register_Read function.
Function name
Table 5- 4 Wild_Register_Read Function
Wild_Register_Read
Function prototype
void Wild_Register_Read (uint Channel,uchar Status)
Behavior description
Enable or disable read wild register data setting register
Input parameter1
Input parameter2
Channel, Select operation channel
Refer to table5-3 for more details on the allowed values for this parameter.
Status, Enable or disable read the wild register data setting register
Return value
None
Note: Input parameter Status values be relate to Channel parameter.
For example: when Channel is Wild_Channel_0, Status only has two input values:
En_Register0 and Dis_Register0.
Table 5-5 describes the Status parameter values.
Table 5- 5 Status Definition
Status
Description
En_Register0
WRDR0 enable read
Dis_Register0
WRDR0 disable read
En_Register1
WRDR1 enable read
Dis_Register1
WRDR1 disable read
En_Register2
WRDR2 enable read
Dis_Register2
WRDR2 disable read
5.2.3 Wild_Register_Status
Table 5-6 describes Wild_Register_Status function.
Function name
Table 5- 6 Wild_Register_Status Function
Wild_Register_Status
Function prototype
void Wild_Register_Status(uint Channel,uchar Status)
Behavior description
Enable or disable wild register work
Input parameter1
Channel, Select operation channel
Refer to table5-3 for more details on the allowed values for this parameter.
Status, Enable or disable wild register operation.
Refer to table5-5 for more details on the allowed values for this parameter.
None
Input parameter2
Return value
Note: Input parameter Status values be relate to Channel parameter.
For example: when Channel is Wild_Channel_0, Status only has two input values:
En_Register0 and Dis_Register0.
MCU-AN- 500022-E-10 – Page 17
Basic API V1.0
Chapter 5 Wild Register Function
5.3
Usage Demo
5.3.1 Modified Data
Sample code:
void initialize (void)
{
Wild_Register_Init (Wild_Channel_0, 0xC080, 0x66);
// 0xC080 is modified address, 0x66 is modified data
Wild_Register_Init (Wild_Channel_1, 0xC081, 0x77);
//0x C081 is modified address, 0x77 is modified data
Wild_Register_Init (Wild_Channel_1, 0xC082, 0x88);
// 0xC082 is modified address, 0x88 is modified data
Wild_Register_Status (Wild_Channel_0, En_Register0);
Wild_Register_Status (Wild_Channel_1, En_Register1);
Wild_Register_Status (Wild_Channel_2, En_Register2);
}
Notes: the modified address and modified data is user setting
5.3.2 Wild Register Disable Work
Sample cod
void wild_register_disable (void)
{
Wild_Register_Status (Wild_Channel_0, Dis_Register0); // disable wild register 0
Wild_Register_Status (Wild_Channel_1, Dis_Register1); // disable wild register 1
Wild_Register_Status (Wild_Channel_2, Dis_Register2); // disable wild register 2
}
5.3.3 Read Wild Register
Sample cod
void wild_register_read_enable (void)
{
Wild_Register_Read (Wild_Channel_0, En_Register0); //enable read wild register 0
Wild_Register_Read (Wild_Channel_1, En_Register1); //enable read wild register 1
Wild_Register_Read (Wild_Channel_2, En_Register2); //enable read wild register 2
}
MCU-AN- 500022-E-10 – Page 18
Basic API V1.0
Chapter 5 Wild Register Function
void wild_register_read_disable (void)
{
Wild_Register_Read (Wild_Channel_0, Dis_Register0);// disable read wild register 0
Wild_Register_Read (Wild_Channel_1, Dis_Register1); // disable read wild register 1
Wild_Register_Read (Wild_Channel_2, Dis_Register2); // disable read wild register 2
}
MCU-AN- 500022-E-10 – Page 19
Basic API V1.0
Chapter 6 Interrupts
6 Interrupts
This chapter introduces all functions of Interrupt library.
In routine, the interrupt library has functions to realize control interrupt, it including set
interrupt, get interrupt status, control interrupt, clear interrupt request and get interrupt
request
MCU-AN- 500022-E-10 – Page 20
Basic API V1.0
Chapter 6 Interrupts
6.1
Interrupts Library Function List
Table 6-1 lists the interrupts library functions.
Table 6- 1 Interrupts Functions
Function name
Description
void External_Interrupt(uint Int_name,uchar State)
Ext_Interrupt enable/ disable
void External_Interrupt_Level(uint Int_name_Level)
Set external interrupt level
uchar External_Interrupt_Request(uint Int_name_Request)
Clear the external interrupt
void Flash_memory_Interrupt(uchar Flash_State)
interrupt enable / disable
void Flash_memory_Level(uchar Flash_Level)
Set interrupt level
uchar Flash_memory_Request(void)
Clear interrupt request
void Watchtimer_Counter_Interrupt(uchar Watchtimer_State)
interrupt enable / disable
void Watchtimer_Counter_Level(uchar Watchtimer_Level)
Set interrupt level
uchar Watchtimer_Counter_Request(void)
Clear interrupt request
void Timebase_Time_Interrupt(uchar Timebase_State)
interrupt enable / disable
void Timebase_Time_Level(uchar Timebase_Level)
Set interrupt level
uchar Timebase_Time_Request(void)
Clear interrupt request
void AD_Converter_Interrupt(uchar AD_State)
interrupt enable / disable
void AD_Converter_Level(uchar AD_Level)
Set interrupt level
uchar AD_Converter_Request(void)
Clear interrupt request
void LIN_UART_Receive_Interrupt(uchar UART_Receive_State)
interrupt enable / disable
void LIN_UART_Receive_Level(uchar UART_Receive_Level)
Set interrupt level
uchar LIN_UART_Receive_Request(void)
Clear interrupt request
void LIN_UART_Transmit_Interrupt(uchar UART_Transmit_State)
interrupt enable / disable
void LIN_UART_Transmit_Level(uchar UART_Transmit_Level)
Set interrupt level
uchar LIN_UART_Transmit_Request(void)
Clear interrupt request
void Composite_Time_0_Lower_Interrupt(uchar Lower_0_State)
interrupt enable / disable
void Composite_Time_0_Lower_Level(uchar Lower_0_Level)
Set interrupt level
uchar Composite_Time_0_Lower_Request(void)
Clear interrupt request
void Composite_Time_0_Upper_Interrupt(uchar Upper_0_State)
interrupt enable / disable
void Composite_Time_0_Upper_Level(uchar Upper_0_Level)
Set interrupt level
uchar Composite_Time_0_Upper_Request(void)
Clear interrupt request
void Composite_Time_1_Upper_Interrupt(uchar Upper_1_State)
interrupt enable / disable
void Composite_Time_1_Upper_Level(uchar Upper_1_Level)
Set interrupt level
Function name
Description
uchar Composite_Time_1_Upper_Request(void)
Clear interrupt request
void Composite_Time_1_Lower_Interrupt(uchar Lower_1_State)
interrupt enable / disable
void Composite_Time_1_Lower_Level(uchar Lower_1_Level)
Set interrupt level
uchar Composite_Time_1_Lower_Request(void)
Clear interrupt request
MCU-AN- 500022-E-10 – Page 21
Basic API V1.0
Chapter 6 Interrupts
6.2
Interrupts Function Detail
6.2.1 External_Interrupt Function
Table 6-2 describes External_Interrupt function.
Table 6- 2 External_Interrupt Function
External_Interrupt
Function name
Function prototype
void External_Interrupt(uint Int_name,uchar State)
Behavior description
Set external interrupt channel and state
Input parameter1
Int_name, extern interrupt channel
Input parameter2
State: Interrupt_Enable / Interrupt_Disable
Return value
None
The function can set the external interrupt enable and disable. Select parameter ‘Int_Name’
and ‘State’ to correct value and will set the interrupt enable or disable.
Table 6-3 describes the Int_name parameter values.
Int_name
Table 6- 3 Int_name Definition
Description
Ext_Int2
Set external Interrupt channel 2
Ext_Int3
Set external Interrupt channel 3
Ext_Int4
Set external Interrupt channel 4
Ext_Int5
Set external Interrupt channel 5
Ext_Int6
Set external Interrupt channel 6
Ext_Int7
Set external Interrupt channel 7
Table 6-4 describes the State parameter values.
Table 6- 4 State Definition
State
Description
Interrupt_Disable
Control external interrupt disable
Interrupt_Enable
Control external interrupt enable
MCU-AN- 500022-E-10 – Page 22
Basic API V1.0
Chapter 6 Interrupts
6.2.2 External_Interrupt_Level Function
Table 6-5 describes External_Interrupt_Level function.
Function name
Table 6- 5 External_Interrupt_Level Function
External_Interrupt_Level
Function prototype
void External_Interrupt_Level(uint Int_name_Level);
Behavior description
set the interrupt level of an interrupt request
Input parameter
Int_name_Level, external interrupt channel and level values
Return value
None
Table 6-6 describes the Int_name_Level parameter values.
Int_name_Level
Table 6- 6 Int_name_Level Definition
Description
Ext_Int2_Level_0
Set external interrupt 2 channel level to 0
Ext_Int2_Level_1
Set external interrupt 2 channel level to 1
Ext_Int2_Level_2
Set external interrupt 2 channel level to 2
Ext_Int2_Level_3
Set external interrupt 2 channel level to 3
Ext_Int3_Level_0
Set external interrupt 3 channel level to 0
Ext_Int3_Level_1
Set external interrupt 3 channel level to 1
Ext_Int3_Level_2
Set external interrupt 3 channel level to 2
Ext_Int3_Level_3
Set external interrupt 3 channel level to 3
Ext_Int4_Level_0
Set external interrupt 4 channel level to 0
Ext_Int4_Level_1
Set external interrupt 4 channel level to 1
Ext_Int4_Level_2
Set external interrupt 4 channel level to 2
Ext_Int4_Level_3
Set external interrupt 4 channel level to 3
Ext_Int5_Level_0
Set external interrupt 5 channel level to 0
Ext_Int5_Level_1
Set external interrupt 5 channel level to 1
Ext_Int5_Level_2
Set external interrupt 5 channel level to 2
Ext_Int5_Level_3
Set external interrupt 5 channel level to 3
Ext_Int6_Level_0
Set external interrupt 6 channel level to 0
Ext_Int6_Level_1
Set external interrupt 6 channel level to 1
Ext_Int6_Level_2
Set external interrupt 6 channel level to 2
Ext_Int6_Level_3
Set external interrupt 6 channel level to 3
Ext_Int7_Level_0
Set external interrupt 7 channel level to 0
Ext_Int7_Level_1
Set external interrupt 7 channel level to1
Ext_Int7_Level_2
Set external interrupt 7 channel level to 2
Ext_Int7_Level_3
Set external interrupt 7 channel level to 3
MCU-AN- 500022-E-10 – Page 23
Basic API V1.0
Chapter 6 Interrupts
6.2.3 External_Interrupt_Request Function
Table 6-7 describes External_Interrupt_Request function.
Function name
Table 6- 7 External_Interrupt_Request Function
External_Interrupt_Request
Function prototype
uchar External_Interrupt_Request(uint Int_name_Request)
Behavior description
return the interrupt request and clear external interrupt request
Input parameter
Int_name_Request
Return value
Interrupt request values: 0(no request) or 1(have request)
The function can control the interrupt. Select parameter ‘Int_name_Request‘ to correct value
and clear request ,return the values of request.
Table 6-8 describes the External_Interrupt_Request parameter values.
Table 6- 8 External_Interrupt_Request Definition
Int_name_Request
Description
Ext_Int2_Request
select external interrupt channel 2
Ext_Int3_Request
select external interrupt channel 3
Ext_Int4_Request
select external interrupt channel 4
Ext_Int5_Request
select external interrupt channel 5
Ext_Int6_Request
select external interrupt channel 6
Ext_Int7_Request
select external interrupt channel 7
6.2.4 Other Interrupt Control Function
Table 6-9 describes other interrupt control function.
Function name
Table 6- 9 Other Interrupt Control Function
Other interrupt control function
Function prototype1
void Flash_memory_Interrupt(uchar Flash_State)
Function prototype2
void Watchtimer_Counter_Interrupt(uchar Watchtimer_State)
Function prototype3
void Timebase_Time_Interrupt(uchar Timebase_State)
Function prototype4
void AD_Converter_Interrupt(uchar AD_State)
Function prototype5
void LIN_UART_Receive_Interrupt(uchar UART_Receive_State)
Function prototype6
void LIN_UART_Transmit_Interrupt(uchar UART_Transmit_State)
Function prototype7
void Composite_Time_0_Lower_Interrupt(uchar Lower_0_State)
Function prototype8
void Composite_Time_0_Upper_Interrupt(uchar Upper_0_State)
Function prototype9
void Composite_Time_1_Upper_Interrupt(uchar Upper_1_State)
Function prototype10
void Composite_Time_1_Lower_Interrupt(uchar Lower_1_State)
Behavior description
Control interrupt status, enable or disable
Input parameter
xx
Return value
None
Note: xx mean all above interrupt function input parameter name.
MCU-AN- 500022-E-10 – Page 24
Basic API V1.0
Chapter 6 Interrupts
Above all the function can set the relevant parameter to control relevant interrupt enable or
disable. Select the relevant parameter to correct value can control the interrupt.
Table 6-10 describes the xx_State parameter values.
Table 6- 10 State Definition
Description
XX_State
Interrupt_Disable
Control interrupt disable
Interrupt_Enable
Control interrupt enable
Note: xx_State mean all above interrupt function input parameter name.
6.2.5 Other Interrupt Level Function
Table 6-11 describes Other interrupt level function.
Function name
Table 6- 11 Other Interrupt Level Function
Other interrupt level function
Function prototype1
void Flash_memory_Level(uchar Flash_Level)
Function prototype2
void Watchtimer_Counter_Level(uchar Watchtimer_Level)
Function prototype3
void Timebase_Time_Level(uchar Timebase_Level)
Function prototype4
void AD_Converter_Level(uchar AD_Level)
Function prototype5
void LIN_UART_Receive_Level(uchar UART_Receive_Level)
Function prototype6
void LIN_UART_Transmit_Level(uchar UART_Transmit_Level)
Function prototype7
void Composite_Time_0_Lower_Level(uchar Lower_0_Level)
Function prototype8
void Composite_Time_0_Upper_Level(uchar Upper_0_Level)
Function prototype9
void Composite_Time_1_Upper_Level(uchar Upper_1_Level)
Function prototype10
void Composite_Time_1_Lower_Level(uchar Lower_1_Level)
Behavior description
Set interrupt level
Input parameter
xx
Return value
None
Note: xx mean all above function input parameter name.
Above all the function can set the relevant interrupt level. Select the relevant parameter to
correct value can set the level of relevant interrupt.
Table 6-12 describes the Relevant_Level parameter values.
Relevant_Level
Table 6- 12 Relevant_Level Definition
Description
Level_0
Relevant interrupt level to 0
Level_1
Relevant interrupt level to 1
Level_2
Relevant interrupt level to 2
Level_3
Relevant interrupt level to 3
MCU-AN- 500022-E-10 – Page 25
Basic API V1.0
Chapter 6 Interrupts
6.2.6 Other Clear and Get Interrupt Request Function
Table 6-13 describes Other clear and get interrupt request function.
Function name
Table 6- 13 Other Clear and Get Interrupt Request Function
Other clear and get interrupt request function
Function prototype1
uchar Flash_memory_Request(void);
Function prototype2
uchar Watchtimer_Counter_Request(void);
Function prototype3
uchar Timebase_Time_Request(void);
Function prototype4
uchar AD_Converter_Request(void);
Function prototype5
uchar LIN_UART_Receive_Request(void);
Function prototype6
uchar LIN_UART_Transmit_Request(void);
Function prototype7
uchar Composite_Time_0_Lower_Request(void);
Function prototype8
uchar Composite_Time_0_Upper_Request(void);
Function prototype9
uchar Composite_Time_1_Upper_Request(void);
Function prototype10
uchar Composite_Time_1_Lower_Request(void);
Behavior description
return the interrupt request and clear interrupt request
Input parameter
None
Return value
Interrupt request values: 0(no request) or 1(have request)
Above all the function can clear the relevant interrupt Request. After run this function will
return the status of relevant interrupt request.
6.3
Usage Demo
6.3.1 External Interrupt
If you want to use the interrupt, it will relate with set interrupt, level and interrupt control.
When you want to set the external interrupt, you can use the External_Interrupt(int
Int_name,uchar State) function. Set the interrupt level use the External_Interrupt_Level(int
Int_name_Level) function. Use the External_Interrupt_Request(int Int_name_request)
function can get the interrupt request and clear it.
The sample as:
Void Interrupt_function(void)
{
External_Interrupt_Level(Ext_Int2_Level_0); //set the extern interrupt and level 0
External_Interrupt(Ext_Int2,Interrupt_Enable);//enable the extern 2 interrupt
}
__interrupt void external_int2( void )
{
……
External_Interrupt_Request(Ext_Int2_Request);// get the interrupt request and clear it
}
6.3.2 Other Interrupt
When you want to set other interrupt, you can use the interrupt set function, interrupt level
set function and interrupt control function.
The sample as:
MCU-AN- 500022-E-10 – Page 26
Basic API V1.0
Chapter 6 Interrupts
void Interrupt_function(void)
{
Timebase_Time_Interrupt(Interrupt_Enable);//set Timebase time interrupt enable
AD_Converter_Interrupt(Interrupt_Disable);//set AD interrupt disable
//set composite time interrupt enable
Composite_Time_1_Lower_Interrupt(Interrupt_Enable);
Timebase_Time_Level(Level_0);
AD_Converter_Level(Level_1);
Composite_Time_1_Lower_Level(Level_2);
}
__interrupt void Interrupt_Timebase_Time(void)
{
……
Interrtup_status = Timebase_Time_Request(); //get the interrupt request and clear it
}
MCU-AN- 500022-E-10 – Page 27
Basic API V1.0
Chapter 7 External Interrupt
7 External Interrupt
This chapter introduces all functions of external interrupt library.
7.1
External Interrupt Library Function List
Table 7-1 lists the External Interrupt library functions.
Table 7- 1 External Interrupt Functions
Function name
Description
void External_Interrupt_Init(uint channel, uchar Edge)
7.2
Setting the external interrupts input channel and
the edge polarity
External Interrupt Function Detail
7.2.1 External_Interrupt_Init function
Table 7-2 describes Standby_Mode_Enter function.
Function name
Table 7- 2 External_Interrupt_Init Function
External_Interrupt_Init
Function prototype
void External_Interrupt_Init(uint Channel, uchar Edge)
Behavior description
Setting the external interrupts input channel and the edge polarity
Input parameter1
Channel, Choose the external interrupts input pin
Input parameter2
Edge, Select the edge polarity
Return value
None
Note: Input parameter Edge values be relate to Channel parameter.
For example: when Channel is Ch_2, Edge only has four input values: No_2, Rising_2, Falling_2 and
Both_2.
Table 7-3 describes the Channel parameter values.
Channel
Table 7- 3 Channel Definition
Description
Ch_2
External interrupt ch.2
Ch_3
External interrupt ch.3
Ch_4
External interrupt ch.4
Ch_5
External interrupt ch.5
Ch_6
External interrupt ch.6
Ch_7
External interrupt ch.7
MCU-AN- 500022-E-10 – Page 28
Basic API V1.0
Chapter 7 External Interrupt
Table 7-4 describes the Edge parameter values.
Table 7- 4 Edge Definition
Edge
Description
No_2
Extern interrupt ch.2 No edge detection
Rising_2
Extern interrupt ch.2 Rising edge
Falling_2
Extern interrupt ch.2 Falling edge
Both_2
Extern interrupt ch.2 Both edge
No_3
Extern interrupt ch.3 No edge detection
Rising_3
Extern interrupt ch.3 Rising edge
Falling_3
Extern interrupt ch.3 Falling edge
Both_3
Extern interrupt ch.3 Both edge
No_4
Extern interrupt ch.4 No edge detection
Rising_4
Extern interrupt ch.4 Rising edge
Falling_4
Extern interrupt ch.4 Falling edge
Both_4
Extern interrupt ch.4 Both edge
No_5
Extern interrupt ch.5 No edge detection
Rising_5
Extern interrupt ch.5 Rising edge
Falling_5
Extern interrupt ch.5 Falling edge
Both_5
Extern interrupt ch.5 Both edge
No_6
Extern interrupt ch.6 No edge detection
Rising_6
Extern interrupt ch.6 Rising edge
Falling_6
Extern interrupt ch.6 Falling edge
Both_6
Extern interrupt ch.6 Both edge
No_7
Extern interrupt ch.7 No edge detection
Rising_7
Extern interrupt ch.7 Rising edge
Falling_7
Extern interrupt ch.7 Falling edge
Both_7
Extern interrupt ch.7 Both edge
7.3
Usage Demo
External_Interrupt_Init()
Select the external interrupt input channel and select the edge polarity. This function can
refer to API for Interrupt.
External_Interrupt_Init(channel_7,Rising_Edge);
//channel 7,rising edge
MCU-AN- 500022-E-10 – Page 29
Basic API V1.0
Chapter 8 Additional Information
8 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- 500022-E-10 – Page 30
Basic API V1.0
Chapter 9 Appendix
9 Appendix
9.1
Tables
Table 2- 1 Clock Library Functions .......................................................................................... 6 Table 2- 2 Clock_Set_CPU_Clock Function ............................................................................ 6 Table 2- 3 CLOCK Definition ................................................................................................... 6 Table 2- 4 Clock_Get_CPU_Clock_Status Function ............................................................... 7 Table 2- 5 Clock_Set_Divide Function ..................................................................................... 7 Table 2- 6 Clock_Div Function ................................................................................................. 7 Table 2- 7 Clock_Get_Divide_Status Function ........................................................................ 8 Table 2- 8 Oscl_Clock_Stabilization_Time Function ............................................................... 8 Table 2- 9 CLOCK_TIME Definition ......................................................................................... 9
Table 3- 1 Clock Supervisor Counter Function ...................................................................... 11 Table 3- 2 Clock_Supervisor_Counter Function .................................................................... 11 Table 3- 3 Mod Definition ....................................................................................................... 11
Table 4- 1 Standby Mode Functions ...................................................................................... 13 Table 4- 2 Standby_Mode_Enter Function ............................................................................ 13 Table 4- 3 STANDBY_MODE Definition ................................................................................ 13 Table 4- 4 Mode_Pin_State function ...................................................................................... 14 Table 4- 5 MODE_PIN_STATUS Definition ........................................................................... 14 Table 4- 6 Software_Reset Function ..................................................................................... 14
Table 5- 1 Wild Register Functions ........................................................................................ 16 Table 5- 2 Wild_Register_Initial Function .............................................................................. 16 Table 5- 3 Channel Definition ................................................................................................ 16 Table 5- 4 Wild_Register_Read Function .............................................................................. 17 Table 5- 5 Status Definition.................................................................................................... 17 Table 5- 6 Wild_Register_Status Function ............................................................................ 17
Table 6- 1 Interrupts Functions .............................................................................................. 21 Table 6- 2 External_Interrupt Function .................................................................................. 22 Table 6- 3 Int_name Definition ............................................................................................... 22 Table 6- 4 State Definition ..................................................................................................... 22 Table 6- 5 External_Interrupt_Level Function ........................................................................ 23 Table 6- 6 Int_name_Level Definition .................................................................................... 23 Table 6- 7 External_Interrupt_Request Function ................................................................... 24 Table 6- 8 External_Interrupt_Request Definition .................................................................. 24 Table 6- 9 Other Interrupt Control Function ........................................................................... 24 Table 6- 10 State Definition ................................................................................................... 25 MCU-AN- 500022-E-10 – Page 31
Basic API V1.0
Chapter 9 Appendix
Table 6- 11 Other Interrupt Level Function ............................................................................ 25 Table 6- 12 Relevant_Level Definition ................................................................................... 25 Table 6- 13 Other Clear and Get Interrupt Request Function ................................................ 26
Table 7- 1 External Interrupt Functions .................................................................................. 28 Table 7- 2 External_Interrupt_Init Function ............................................................................ 28 Table 7- 3 Channel Definition ................................................................................................ 28 Table 7- 4 Edge Definition ..................................................................................................... 29 MCU-AN- 500022-E-10 – Page 32