1
- #if defined(_SAMD21_) || defined(ARDUINO_QTPY_M0)
2
1
3
2
#include " samd21_mcu.h"
3
+
4
+ #if defined(_SAMD21_)
5
+
4
6
#include " ../../hardware_api.h"
5
7
#include " ../../../drivers/hardware_specific/samd/samd_mcu.h"
6
8
@@ -19,8 +21,8 @@ static void setupADCEventTriggerFromDriver(const SAMDHardwareDriverParams *par,
19
21
while (ADC->STATUS .bit .SYNCBUSY );
20
22
21
23
ADC->REFCTRL .reg = ADC_REFCTRL_REFSEL_INTVCC1;
22
- ADC->CTRLB .reg = ADC_CTRLB_PRESCALER_DIV32 | ADC_CTRLB_RESSEL_12BIT;
23
- // ADC->CTRLB.bit.FREERUN = 0;
24
+ ADC->CTRLB .reg = ADC_CTRLB_PRESCALER_DIV16 | ADC_CTRLB_RESSEL_12BIT;
25
+ ADC->CTRLB .bit .FREERUN = 0 ;
24
26
while (ADC->STATUS .bit .SYNCBUSY );
25
27
26
28
ADC->INPUTCTRL .bit .MUXPOS = g_APinDescription[_pinA].ulADCChannelNumber ;
@@ -36,7 +38,7 @@ static void setupADCEventTriggerFromDriver(const SAMDHardwareDriverParams *par,
36
38
NVIC_EnableIRQ (ADC_IRQn);
37
39
38
40
// --- Configure Event System ---
39
- uint8_t tcc_num = par->tccPinConfigurations [0 ]->tcc .tccn ;
41
+ uint8_t tcc_num = par->tccPinConfigurations [1 ]->tcc .tccn ;
40
42
41
43
// --- Enable event output on the PWM timer (important!) ---
42
44
Tcc* tcc = nullptr ;
@@ -83,11 +85,12 @@ static void setupADCEventTriggerFromDriver(const SAMDHardwareDriverParams *par,
83
85
84
86
// ADC interrupt (switch between A, B, C)
85
87
void ADC_Handler () {
86
-
88
+ // digitalWrite(13,HIGH);
87
89
// check if we are in high-side or low-side current sense
88
90
is_high_side = !is_high_side;
89
91
if (is_high_side){
90
92
ADC->INTFLAG .reg = ADC_INTFLAG_RESRDY;
93
+ // digitalWrite(13,LOW);
91
94
return ;
92
95
}
93
96
@@ -113,6 +116,7 @@ void ADC_Handler() {
113
116
}
114
117
ADC->INTFLAG .reg = ADC_INTFLAG_RESRDY;
115
118
}
119
+ // digitalWrite(13,LOW);
116
120
}
117
121
118
122
0 commit comments