Use a Microcontroller’s Functionality to Quickly Implement Analog Signal Chains in Compact Designs
Contributed By DigiKey's North American Editors
2019-02-05
With the addition of these analog signal conditioning circuits on a microcontroller, developers now have an effective way to configure these components to meet a broad range of analog interface requirements for wearables and other IoT devices by manipulating only a few lines of code.
Interfacing a sensor to a microcontroller
Integrated analog components
คัดลอก
//Select external source for both positive and negative inputs
SAC_OA_init(SAC0_BASE, SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL, SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL);
//Select low speed and low power mode
SAC_OA_selectPowerMode(SAC0_BASE, SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER)
// Enable OA
SAC_OA_enable(SAC0_BASE);
// Enable SAC
SAC_enable(SAC0_BASE);
SAC_OA_init
SAC_OA_selectPowerMode
คัดลอก
//Select internal shared reference as DAC reference voltage
SAC_DAC_selectRefVoltage(SAC0_BASE, SAC_DAC_SECONDARY_REFERENCE);
//Select the load trigger for DAC data latch
//DAC always loads data from DACDAT at the positive edge of Timer output TB2.1
SAC_DAC_selectload(SAC0_BASE, SAC_DAC_LOAD_DEVICE_SPECIFIC_0);
//Enable DAC Interrupt
SAC_DAC_interruptEnable(SAC0_BASE);
//Write data to DAC Data Register SACxDAT
//DAC_data is an unsigned int type variable defined by user SAC_DAC_setData(SAC0_BASE, DAC_data);
//Enable DAC
SAC_DAC_enable(SAC0_BASE);
//Select internal DAC for positive input and PGA source for negative input
SAC_OA_init(SAC0_BASE, SAC_OA_POSITIVE_INPUT_SOURCE_DAC,
SAC_OA_NEGATIVE_INPUT_SOURCE_PGA);
//Select Buffer Mode
SAC_PGA_setMode(SAC0_BASE, SAC_PGA_MODE_BUFFER);
//Enable OA
SAC_OA_enable(SAC0_BASE);
//Enable SAC
SAC_enable(SAC0_BASE);
Multiple stages
SAC_OA_init
SAC0_BASE
SAC_OA_NEGATIVE_INPUT_SOURCE_PGA
SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA
คัดลอก
//Configure Op-Amp functionality
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
GPIO_PIN1 | GPIO_PIN3 | GPIO_PIN2,
GPIO_TERNARY_MODULE_FUNCTION);
//Select external source for both positive and negative inputs
SAC_OA_init(SAC2_BASE, SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL,
SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL);
//Select low speed and low power mode
SAC_OA_selectPowerMode(SAC2_BASE, SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER);
SAC_OA_enable(SAC2_BASE); // Enable SAC2 OA
SAC_enable(SAC2_BASE); // Enable SAC2
//Select external source for both positive and negative inputs
SAC_OA_init(SAC0_BASE, SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA,
SAC_OA_NEGATIVE_INPUT_SOURCE_PGA);
SAC_OA_enable(SAC0_BASE); // Enable SAC0 OA
SAC_enable(SAC0_BASE); // Enable SAC0
SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA
บทสรุป

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of DigiKey or official policies of DigiKey.