Skip to content

Commit

Permalink
Update ADCSetup.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bexin3 authored Jan 25, 2023
1 parent 69ba265 commit c63aba8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ADCSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ void ADC0Setup(bool DacRef, int Res, int Samp, int ADCClk, int ADCDiv, int BaseV
DACSetup(BaseV); //Setup DAC if needed
};

ADC0->CALIB.reg = ADC_CALIB_BIASCOMP(0x7) | ADC_CALIB_BIASREFBUF(0x7);

ADC0->CALIB.reg = ADC_CALIB_BIASREFBUF(((*((uint32_t *) ADC0_FUSES_BIASREFBUF_ADDR) & ADC0_FUSES_BIASREFBUF_Msk) >> ADC0_FUSES_BIASREFBUF_Pos))
| ADC_CALIB_BIASCOMP(((*((uint32_t *) ADC0_FUSES_BIASCOMP_ADDR) & ADC0_FUSES_BIASCOMP_Msk) >> ADC0_FUSES_BIASCOMP_Pos));

if (DacRef) {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
Expand Down Expand Up @@ -129,12 +131,14 @@ void ADC1Setup(bool DacRef, int Res, int Samp, int ADCClk, int ADCDiv, int BaseV
DACSetup(BaseV); //Setup DAC if needed
};

ADC1->CALIB.reg = ADC_CALIB_BIASCOMP(0x7) | ADC_CALIB_BIASREFBUF(0x7);

ADC1->CALIB.reg = ADC_CALIB_BIASREFBUF(((*((uint32_t *) ADC1_FUSES_BIASREFBUF_ADDR) & ADC1_FUSES_BIASREFBUF_Msk) >> ADC1_FUSES_BIASREFBUF_Pos))
| ADC_CALIB_BIASCOMP(((*((uint32_t *) ADC1_FUSES_BIASCOMP_ADDR) & ADC1_FUSES_BIASCOMP_Msk) >> ADC1_FUSES_BIASCOMP_Pos));

if (DacRef) {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
ADC1->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
} else {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC2_Val;
ADC1->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC2_Val;
};


Expand Down

0 comments on commit c63aba8

Please sign in to comment.