Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method.
More...
Peripheral features and how this peripheral works
The Operational Amplifier (OPAMP) module supports flexible amplifier application.
Features
- Up to four sets of register configuration.
- OPAMP supports four configuration registers(CFG0 to CFG3), only one of which validates all the time.
- OPAMP configuartion registers can be either software or other peripherals through inter-module connections.
- Selectable non-inverting input and inverting input. Both non-inverting and inverting input the 4-to-1 multiplex which can can select analog input signals from either pins or internal references.
- Configurable work mode. OPAMP supports three work modes:
- Buffer mode: In this mode, OPAMP operates as a buffer and gain is 1X.
- Internal gain mode: Based on internal resistance net, this mode supports non-inverting 2X/4X/8X/16X gain.
- External gain mode: In this mode, amplifier negative input switches to external resistance net. Flexible gain could be achieved by different external resistance nets.
- Different power modes. OPAMP supports high speed mode and low power mode.
- High speed mode means higher current consumption with faster slew rate, and wider unity gain bandwidth performance.
- Low power mode means lower current consumption with slower slew rate, and narrower unity gain bandwidth performance.
How this peripheral works
- Configure OPAMP output pin and input pin according to use case.
- Set the control register, the configuration sets to use, power mode, load mode, and so on.
- Set the configuartion register, the configuration sets to use, Gain Multiplier, inverting and non-inverting input selection, and so on.
- Enable the configuration load.
- Enable OPAMP and start work.
How this driver is designed to make this peripheral works
With OPAMP_Init, the OPAMP module could be set to a defined state and starts to work.
OPAMP driver provides methods to configure the OPAMP module:
- Whole module configuration update by OPAMP_Init. This function sets all configurations and enables the configuration load, the new configuration is loaded at the time determined by load mode.
OPAMP driver also provides APIs to get and clear configuration load completion flags.
How to use this driver
- Configure and enable module clock before calling this driver's API.
- Options to configure OPAMP: software-controlled or peripherals-controlled.
- Enable OPAMP interrupt in system interrupt controller if necessary.
- Configure the output pin and input pin according to use case.
- Prepare the configuration structure opamp_config_t, and call the function OPAMP_Init. Then the OPAMP starts working. The function OPAMP_GetDefaultConfig helps filling opamp_config_t with default value which user can modify.
Typical Use Case
- OPAMP_basic peripherals control OPAMP
- Delayed load mode initialization.
- Immediate load mode initialization.
- Update initialization configuration. In this type of use case, the initialized configuration shall be updated. The gain will be changed, for example, while using the peripheral to control the OPAMP in a delayed load mode.
- Switch OPAMP peripheral control mode to software control mode.
- OPAMP_basic software control OPAMP
- Delayed load mode initialization.
- Immediate load mode initialization.
- Use new configuration set. In this type of use case, configuration set would be switched from current one to another one.
- Switch OPAMP software control mode to peripheral control mode. In this type of use case, from software control mode to external control mode, and the gain is switched from x1 to X2.