int main(void) { CHIP_Init(); /*Turn on the DAC clock*/ CMU_ClockEnable(cmuClock_DAC0, true); /*Define the configuration for OPA0 and OPA1*/ OPAMP_Init_TypeDef configuration0 = OPA_INIT_DIFF_DRIVER_OPA0; OPAMP_Init_TypeDef configuration1 = OPA_INIT_DIFF_DRIVER_OPA1; /*Enable the opamps*/ OPAMP_Enable(DAC0, OPA0, &configuration0); OPAMP_Enable(DAC0, OPA1, &configuration1); /*Never end*/ while(1); }
int main(void) { CHIP_Init(); CMU_ClockEnable(cmuClock_DAC0, true); /*Define the configuration for OPA2*/ //OPAMP_Init_TypeDef configuration = OPA_INIT_UNITY_GAIN_OPA2; OPAMP_Init_TypeDef configuration1 = OPA_INIT_NON_INVERTING_OPA2; OPAMP_Init_TypeDef configuration2 = OPA_INIT_NON_INVERTING; OPAMP_Enable(DAC0, OPA2, &configuration1); OPAMP_Enable(DAC0, OPA0, &configuration2); /*Never end*/ while(1) { led = !led; wait(0.5); }; }
int main(void) { CHIP_Init(); /*Turn on the DAC clock.*/ CMU_ClockEnable(cmuClock_DAC0, true); /*configure and enable the DAC.*/ DAC_setup(); DAC_Enable(DAC0, 0, true); /*Write data to registers. V1 = 1.0*/ DAC0->CH0DATA = (uint32_t)((1.0 * 4096) / 3.3); /*configure OPA0, OPA1 and OPA2.*/ OPAMP_Init_TypeDef configuration0 = OPA_INIT_DIFF_RECEIVER_OPA0 ; OPAMP_Init_TypeDef configuration2 = OPA_INIT_DIFF_RECEIVER_OPA2 ; /*Redefine the resistances. Want to divide the difference by 3.*/ configuration2.resSel = opaResSelDefault; configuration0.resSel = opaResSelR2eq3R1; /*OPA2 positive input = VSS*/ configuration2.resInMux = opaResInMuxVss; /*Enable OPA0 and OPA2. All the configurations are set.*/ OPAMP_Enable(DAC0, OPA0, &configuration0); OPAMP_Enable(DAC0, OPA2, &configuration2); /*Disable OPA0. This is done because we want to use OPA0 as a part of the DAC. The configurations set above are still there.*/ DAC0->OPACTRL &= ~DAC_OPACTRL_OPA0EN; /*Never end.*/ while(1); }
int main(void) { CHIP_Init(); /*Turn on the DAC clock*/ CMU_ClockEnable(cmuClock_DAC0, true); /*Define the configuration for OPA2*/ OPAMP_Init_TypeDef configuration = OPA_INIT_UNITY_GAIN_OPA2; /*Enable OPA2*/ OPAMP_Enable(DAC0, OPA2, &configuration); /*Never end*/ while(1); }