In this use case, the OPAMP0 is configured as "Non-Inverting PGA" mode, refer to the second mode of "Built-in Modes" in the device datasheet.
You can give a signal on OA0POS and watch the output on OA0OUT through an oscilloscope.
Setup
Prerequisites
There are no special setup requirements for this use case.
Code
Copy-paste the following setup code to your user application:
{
conf.config_common.r1_enable = true;
conf.config_common.r2_out = true;
opamp0_pos_pin_conf.mux_position = MUX_PA06B_OPAMP_OAPOS0;
opamp0_out_pin_conf.mux_position = MUX_PA07B_OPAMP_OAOUT0;
}
Add to user application initialization (typically the start of main()
):
Workflow
- Create an OPAMP0 configuration struct, which can be filled out to adjust the configuration of OPAMP0.
- Initialize the OPAMP module.
- Initialize the OPAMP0 configuration struct with the module's default values.
- Note
- This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
- Adjust the configuration struct to set the OPAMP0 as "Non-Inverting PGA" mode.
conf.config_common.r1_enable = true;
conf.config_common.r2_out = true;
- Note
- The existing configuration struct may be re-used, as long as any values that have been altered from the default settings are taken into account by the user application.
- Set up OA0POS pin and OA0OUT pin.
opamp0_pos_pin_conf.mux_position = MUX_PA06B_OPAMP_OAPOS0;
opamp0_out_pin_conf.mux_position = MUX_PA07B_OPAMP_OAOUT0;
- Write OPAMP0 configuration to the hardware module.
- Enable OPAMP0.
- Wait for the output ready.
Use Case
Code
Copy-paste the following code to your user application: