Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/current_sense/hardware_specific/samd21_mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ float SAMDCurrentSenseADCDMA::toVolts(uint16_t counts) {

void SAMDCurrentSenseADCDMA::initPins(){

pinMode(pinAREF, INPUT);
if (pinAREF>=0)
pinMode(pinAREF, INPUT);
pinMode(pinA, INPUT);
pinMode(pinB, INPUT);

Expand Down Expand Up @@ -169,8 +170,10 @@ void SAMDCurrentSenseADCDMA::initADC(){
//ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0_Val; // 2.2297 V Supply VDDANA
ADC->INPUTCTRL.bit.GAIN = ADC_INPUTCTRL_GAIN_1X_Val; // Gain select as 1X
// ADC->INPUTCTRL.bit.GAIN = ADC_INPUTCTRL_GAIN_DIV2_Val; // default
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA;
// ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0;
if (pinAREF>=0)
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA;
else
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0;
ADCsync(); // ref 31.6.16

/*
Expand Down
6 changes: 4 additions & 2 deletions src/current_sense/hardware_specific/samd21_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef CURRENT_SENSE_SAMD21_H
#define CURRENT_SENSE_SAMD21_H

// #define SIMPLEFOC_SAMD_DEBUG
#define SIMPLEFOC_SAMD_DEBUG
#if !defined(SIMPLEFOC_SAMD_DEBUG_SERIAL)
#define SIMPLEFOC_SAMD_DEBUG_SERIAL Serial
#endif
Expand All @@ -18,6 +18,8 @@
} dmacdescriptor ;


// AREF pin is 42

class SAMDCurrentSenseADCDMA
{

Expand Down Expand Up @@ -64,4 +66,4 @@ class SAMDCurrentSenseADCDMA



#endif
#endif
Loading