Fujitsu Semiconductor (Shanghai) Co., Ltd.
Application Note
MCU-AN-500080-E-10
F²MC-8FX FAMILY
8-BIT MICROCONTROLLER
MB95F430 SERIES
OPERATIONAL AMPLIFIER
APPLICATION NOTE
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
CONTENTS
CONTENTS
Revision History..........................................................................................................................2
Table of Contents........................................................................................................................3
Introduction ..........................................................................................................................4
Amplifier Overview ...............................................................................................................5
2.1 Block Diagram of Operational Amplifier.....................................................................6
2.2 Pins of Operational Amplifier .....................................................................................6
2.3 OPAMP Control Register...........................................................................................7
Operations of Operational Amplifier.....................................................................................9
Amplifier setting procedure ................................................................................................10
Amplifier Driver ..................................................................................................................11
5.1 Peripheral Usage.....................................................................................................11
5.2 Driver Code..............................................................................................................11
5.2.1 General Definition ............................................................................................11
5.2.2 Amplifier Routine..............................................................................................12
Typical Application.............................................................................................................13
6.1 HW Design...............................................................................................................13
6.2 Sample Code...........................................................................................................13
More Information................................................................................................................14
Appendix............................................................................................................................15
Sample Code .....................................................................................................................16
MCU-AN-500080-E-10- Page 3
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 1 Introduction
1 Introduction
In this document, we will introduce how to use the amplifier function on the MB95F430 series.
Chapter 2 gives an overview on operational amplifier.
Chapter 3 introduces the operations of operational amplifier.
Chapter 4 introduces Operational Amplifier setting procedure.
Chapter 5 introduces amplifier drivers.
Chapter 6 introduces amplifier application demo.
MCU-AN-500080-E-10 - Page 4
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 2 Amplifier Overview
2 Amplifier Overview
The operational amplifier can be used to sense the ground current, and support front-end
analog signal conditioning prior to A/D conversion. It can operate in either closed loop mode or
standalone open loop mode.
■ Closed Loop Mode
The operational amplifier can be configured as a non-inverting closed loop operational
amplifier.
It has six software-selectable closed loop gain options for ground current sensing according to
different sense voltage values.
■ Standalone Open Loop Mode
In this mode, the operational amplifier input pins are connected to external signals without any
output feedback.
The standalone open loop mode is designed for users that can choose more flexible gain using
external resistors.
MCU-AN-500080-E-10- Page 5
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 2 Amplifier Overview
2.1
Block Diagram of Operational Amplifier
Figure 1 Block Diagram of Operational Amplifier
2.2
Pins of Operational Amplifier
The OPAMP uses the OPAMP_P pin and the OPAMP_N pin as the analog input pins of the
operational amplifier, and uses the OPAMP_O pin as the analog output pin of the operational
amplifier.
When GS [5] is set to "1B" and GS [4:0] is set to "00000B", the OPAMP will work as a
standalone open loop operational amplifier.
When GS [5] is set to "0B", the OPAMP will work as a non-inverting closed loop operational
amplifier. It provides six different closed loop gain settings through the software.
MCU-AN-500080-E-10 - Page 6
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 2 Amplifier Overview
2.3
OPAMP Control Register
The OPAMP control register (OPCR) is used to turn on and off the OPAMP, to enable and
disable OPAMP analog output, and to enable and disable OPAMP analog input.
The register can also be used to set the OPAMP to operate as a standalone open loop
operational amplifier, or a non-inverting closed loop operational amplifier with six different
closed loop gain settings that can be selected by the software.
Figure 2 OPAMP Control Register
MCU-AN-500080-E-10- Page 7
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 2 Amplifier Overview
■ Functions of Bits in OPAMP Control Register (OPCR)
■ OPAMP Operating Mode Settings
Notes:
•While the OPAMP is operating, modifying the settings of RES2, RES1 and RES0 is allowed,
however, do not use the output signal of the OPAMP or execute A/D conversion until OPAMP
output becomes stable.
•It is recommended to turn off the operational amplifier before modifying the settings of RES2,
RES1 and RES0.
MCU-AN-500080-E-10 - Page 8
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 3 Operations of Operational Amplifier
3 Operations of Operational Amplifier
The operational amplifier can be activated by setting the PD bit in the OPCR register using the
software. It can operate in closed loop mode or open loop mode, depending on the settings of
the RES2, RES1 and RES0 bits in the OPCR register.
■ Activating Operational Amplifier by Software
The settings shown in Figure 24.5-1 are required for activating the operational amplifier using
the software.
Figure 3 Settings for Activating Operational Amplifier
After the bits in the OPCR register are set as shown above, the operational amplifier will not
start operating until it stabilizes.
■ Operations of OPAMP in Closed Loop Mode
Before being activated, the operational amplifier can be set to operate in closed loop mode in
advance by setting RES[2:0] in the OPCR register to "000B", "001B", "010B", "011B", "100B" or
"101B".
Six different closed loop gains are available to be used in closed loop mode. Select a desired
closed loop gain by setting RES[2:0] in OPCR to the value corresponding to that gain.
■ Operations of OPAMP in Open Loop Mode
Before being activated, the operational amplifier can be set to operate in open loop mode in
advance by setting RES [2:0] in the OPCR register to "110B".
MCU-AN-500080-E-10- Page 9
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 4 Amplifier setting procedure
4 Amplifier setting procedure
Below is an example of procedure for setting the operational amplifier.
● Initial settings
1) Set both OPCR: OPID and OPCR: OPOD to "0" to enable both OPAMP analog input and
OPAMP analog output.
2) Set the feedback resistor and RES [2:0] in OPCR.
3) Set OPCR: PD to "0" to turn on the operational amplifier.
4) Wait until the operation amplifier stabilizes.
5) Start A/D conversion if necessary.
MCU-AN-500080-E-10 - Page 10
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 5 Amplifier Driver
5 Amplifier Driver
This is OPAMP driver description.
5.1 Peripheral Usage
The MCU pins used as below:
OPAMP_N,used as amplifier negative input;
OPAMP_P,used as amplifier positive input;
OPAMP_O,used as amplifier output;
5.2 Driver Code
5.2.1 General Definition
typedef unsigned char BOOLEAN;
typedef unsigned char INT8U;
/* Unsigned 8 bit quantity */
/* Signed 8 bit quantity */
/* Unsigned 16 bit quantity */
/* Signed 16 bit quantity */
/* Unsigned 32 bit quantity */
/* Signed 32 bit quantity */
typedef signed
typedef unsigned int
typedef signed int
char INT8S;
INT16U;
INT16S;
typedef unsigned long INT32U;
typedef signed
long INT32S;
#define BOOL
#define BYTE
#define UBYTE
#define WORD
#define UWORD
#define LONG
#define ULONG
#define UCHAR
#define UINT
BOOLEAN
INT8U
INT8U
INT16U
INT16U
INT32S
INT32U
INT8U
INT16U
INT32U
#define DWORD
#define TRUE
#define FALSE
1
0
#define BYTE_LO(w)
#define BYTE_HI(w)
((UBYTE)(w))
((UBYTE)(((UWORD)(w)>>8)&0xFF))
MCU-AN-500080-E-10- Page 11
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 5 Amplifier Driver
5.2.2 Amplifier Routine
void AmpOpenLoop()
Return
: none.
: none.
Parameters
Description
Example
: open-loop setting.
: AmpOpenLoop();
void AmpOpenLoop()
{
DDR6_P60=0;
DDR6_P61=0;
DDR6_P62=1;
OPCR=0x60;//Amplifier gain is R3/R1
}
void AmpCloseLoop()
Return
: none.
: none.
Parameters
Description
Example
: close-loop setting.
: AmpCloseLoop();
void AmpCloseLoop()
{
DDR6_P60=0;
DDR6_P61=0;
DDR6_P62=1;
OPCR=0x40;//Amplifier gain is 20V/V
}
MCU-AN-500080-E-10 - Page 12
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 6 Typical Application
6 Typical Application
This is the typical application introduction.
6.1 HW Design
In this application, we will test the operational amplifier in the MB95F430K. The HW is designed
as below. The R1, R2, R3 is used in open-loop amplifier.
Figure 4 Hardware Design
6.2 Sample Code
void main(void)
Return
: none.
Parameters : none;
Description
Example
: system main programm.
: main();
void main(void)
{
__DI();
__set_il(3);
InitIrqLevels();
WDTH =0xA5;//Disable WTG
WDTL =0x96;
WATR =0xEE;
SYCC =0xF0;//Main Clock
SYCC2=0xF4;//Main Clock
SYSC =0xBC;//BUZZ(P01)
SYSC2 =0x02;//PPG(P73),Disable I2C
while(!STBC_MRDY);
__EI();
AmpOpenLoop();
AmpCloseLoop();
}
MCU-AN-500080-E-10- Page 13
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 7 More Information
7 More Information
For more Information on FUJITSU Semiconductor products, visit the following websites:
English version:
Simplified Chinese Version:
MCU-AN-500080-E-10 - Page 14
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 8 Appendix
8 Appendix
Figure 1 Block Diagram of Operational Amplifier................................................................................6
Figure 2 OPAMP Control Register.........................................................................................................7
Figure 3 Settings for Activating Operational Amplifier........................................................................9
Figure 4 Hardware Design....................................................................................................................13
MCU-AN-500080-E-10- Page 15
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 9 Sample Code
9 Sample Code
main.c
#include "mb95430.h"
#include "TypeDef.h"
/*---------------------------------------------------------------------------*/
/* Amplifier Setting
/*---------------------------------------------------------------------------*/
void AmpOpenLoop()
{
DDR6_P60=0;
DDR6_P61=0;
DDR6_P62=1;
OPCR=0x60;//Amplifier gain is R3/R1
}
void AmpCloseLoop()
{
DDR6_P60=0;
DDR6_P61=0;
DDR6_P62=1;
OPCR=0x40;//Amplifier gain is 20V/V
}
void main(void)
{
__DI();
__set_il(3);
InitIrqLevels();
WDTH =0xA5;
WDTL =0x96;
WATR =0xEE;
SYCC =0xF0;//Main Clock
SYCC2=0xF4;//Main Clock
SYSC =0xBC;//BUZZ(P01)
SYSC2 =0x02;//PPG(P73),Disable I2C
while(!STBC_MRDY);
__EI();
AmpOpenLoop();
AmpCloseLoop();
}
VECTORS.C
#include "mb95430.h"
void InitIrqLevels(void)
{
MCU-AN-500080-E-10 - Page 16
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 9 Sample Code
/* ILRx
ILR0 = 0xFF;
IRQs defined by ILRx */
// IRQ0: external interrupt ch0 | ch4
// IRQ1: external interrupt ch1 | ch5
// IRQ2: external interrupt ch2 | ch6
// IRQ3: external interrupt ch3 | ch7
ILR1 = 0xFF;
ILR2 = 0xFF;
ILR3 = 0xFF;
ILR4 = 0xFF;
ILR5 = 0xFF;
// IRQ4: UART/SIO ch0
// IRQ5: 8/16-bit timer ch0 (lower)
// IRQ6: 8/16-bit timer ch0 (upper)
// IRQ7: Output Compare ch0
// IRQ8: Output Compare ch1
// IRQ9: none
// IRQ10: Voltage Compare ch0
// IRQ11: Voltage Compare ch1
// IRQ12: Voltage Compare ch2
// IRQ13: Voltage Compare ch3
// IRQ14: 16-bit free run timer
// IRQ15: 16-bit PPG0
// IRQ16: I2C ch0
// IRQ17: none
// IRQ18: 10-bit A/D-converter
// IRQ19: Timebase timer
// IRQ20: Watch timer
// IRQ21: none
// IRQ22: none
// IRQ23: Flash Memory
}
/*---------------------------------------------------------------------------
Prototypes
Add your own prototypes here. Each vector definition needs is proto-
type. Either do it here or include a header file containing them.
-----------------------------------------------------------------------------*/
__interrupt void DefaultIRQHandler(void);
/*---------------------------------------------------------------------------
Vector definiton
Use following statements to define vectors.
All resource related vectors are predefined.
Remaining software interrupts can be added hereas well.
-----------------------------------------------------------------------------*/
#pragma intvect DefaultIRQHandler 0
#pragma intvect DefaultIRQHandler 1
#pragma intvect DefaultIRQHandler 2
#pragma intvect DefaultIRQHandler 3
// IRQ0: external interrupt ch0 | ch4
// IRQ1: external interrupt ch1 | ch5
// IRQ2: external interrupt ch2 | ch6
// IRQ3: external interrupt ch3 | ch7
#pragma intvect DefaultIRQHandler 4
#pragma intvect DefaultIRQHandler 5
// IRQ4: UART/SIO ch0
// IRQ5: 8/16-bit timer ch0 (lower)
MCU-AN-500080-E-10- Page 17
Download from Www.Somanuals.com. All Manuals Search And Download.
Operational Amplifier Version 1.0
Chapter 9 Sample Code
#pragma intvect DefaultIRQHandler 6
#pragma intvect DefaultIRQHandler 7
// IRQ6: 8/16-bit timer ch0 (upper)
// IRQ7: Output Compare ch0
#pragma intvect DefaultIRQHandler 8
#pragma intvect DefaultIRQHandler 9
// IRQ8: Output Compare ch1
// IRQ9: none
#pragma intvect DefaultIRQHandler 10 // IRQ10: Voltage Compare ch0
#pragma intvect DefaultIRQHandler 11 // IRQ11: Voltage Compare ch1
#pragma intvect DefaultIRQHandler 12 // IRQ12: Voltage Compare ch2
#pragma intvect DefaultIRQHandler 13 // IRQ13: Voltage Compare ch3
#pragma intvect DefaultIRQHandler 14 // IRQ14: 16-bit free run timer
#pragma intvect DefaultIRQHandler 15 // IRQ15: 16-bit PPG0
#pragma intvect DefaultIRQHandler 16 // IRQ16: I2C ch0
#pragma intvect DefaultIRQHandler 17 // IRQ17: none
#pragma intvect DefaultIRQHandler 18 // IRQ18: 10-bit A/D-converter
#pragma intvect DefaultIRQHandler 19 // IRQ19: Timebase timer
#pragma intvect DefaultIRQHandler 20 // IRQ20: Watch timer
#pragma intvect DefaultIRQHandler 21 // IRQ21: none
#pragma intvect DefaultIRQHandler 22 // IRQ22: none
#pragma intvect DefaultIRQHandler 23 // IRQ23: Flash Memory
/*---------------------------------------------------------------------------
DefaultIRQHandler()
This function is a placeholder for all vector definitions.
Either use your own placeholder or add necessary code here
(the real used resource interrupt handlers should be defined in the main.c).
-----------------------------------------------------------------------------*/
__interrupt void DefaultIRQHandler(void)
{
__DI();
while(1)
// disable interrupts
// halt system
__wait_nop();
}
MCU-AN-500080-E-10 - Page 18
Download from Www.Somanuals.com. All Manuals Search And Download.
|