Skip to content

Instantly share code, notes, and snippets.

@erikformella
Last active May 5, 2021 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikformella/8743ea868254646f08b351211b6b156d to your computer and use it in GitHub Desktop.
Save erikformella/8743ea868254646f08b351211b6b156d to your computer and use it in GitHub Desktop.
adc mux bug
#include "daisy_seed.h"
using namespace daisy;
DaisySeed seed;
#define PIN_KNOB_MUX 25
#define PIN_MUX_SEL_0 26
#define PIN_MUX_SEL_1 27
#define PIN_MUX_SEL_2 28
#define PIN_CV_1 17
#define PIN_CV_2 18
#define PIN_CV_3 19
#define PIN_CV_4 20
#define PIN_CV_5 21
#define PIN_CV_6 22
#define PIN_CV_7 23
#define PIN_CV_8 24
#define ADC_CHANNELS 9
static void callback(float** in, float** out, size_t size) {}
int main(void) {
seed.Configure();
seed.Init();
AdcChannelConfig adc_config[ADC_CHANNELS];
adc_config[0].InitMux(seed.GetPin(PIN_KNOB_MUX), 8,
seed.GetPin(PIN_MUX_SEL_0), seed.GetPin(PIN_MUX_SEL_1),
seed.GetPin(PIN_MUX_SEL_2));
adc_config[1].InitSingle(seed.GetPin(PIN_CV_1));
adc_config[2].InitSingle(seed.GetPin(PIN_CV_2));
adc_config[3].InitSingle(seed.GetPin(PIN_CV_3));
adc_config[4].InitSingle(seed.GetPin(PIN_CV_4));
adc_config[5].InitSingle(seed.GetPin(PIN_CV_5));
adc_config[6].InitSingle(seed.GetPin(PIN_CV_6));
adc_config[7].InitSingle(seed.GetPin(PIN_CV_7));
adc_config[8].InitSingle(seed.GetPin(PIN_CV_8));
// NOTE: ADC_CHANNELS=9 makes the adc stop working
seed.adc.Init(adc_config, ADC_CHANNELS);
// seed.adc.Init(adc_config, 8);
seed.adc.Start();
// seed.StartAudio(callback);
seed.StartLog(false);
uint32_t time = seed.system.GetUs();
seed.PrintLine("starting logs\n");
while (1) {
uint32_t new_time = seed.system.GetUs();
if (new_time - time > 500000) {
time = new_time;
seed.PrintLine("-------- ADC values: --------");
float mux_1 = seed.adc.GetMuxFloat(0, 0);
float mux_2 = seed.adc.GetMuxFloat(0, 1);
float mux_3 = seed.adc.GetMuxFloat(0, 2);
float mux_4 = seed.adc.GetMuxFloat(0, 3);
float mux_5 = seed.adc.GetMuxFloat(0, 4);
float mux_6 = seed.adc.GetMuxFloat(0, 5);
float mux_7 = seed.adc.GetMuxFloat(0, 6);
float mux_8 = seed.adc.GetMuxFloat(0, 7);
seed.PrintLine("mux_1: %f", mux_1);
seed.PrintLine("mux_2: %f", mux_2);
seed.PrintLine("mux_3: %f", mux_3);
seed.PrintLine("mux_4: %f", mux_4);
seed.PrintLine("mux_5: %f", mux_5);
seed.PrintLine("mux_6: %f", mux_6);
seed.PrintLine("mux_7: %f", mux_7);
seed.PrintLine("mux_8: %f", mux_8);
float cv_1 = seed.adc.GetFloat(1);
float cv_2 = seed.adc.GetFloat(2);
float cv_3 = seed.adc.GetFloat(3);
float cv_4 = seed.adc.GetFloat(4);
float cv_5 = seed.adc.GetFloat(5);
float cv_6 = seed.adc.GetFloat(6);
float cv_7 = seed.adc.GetFloat(7);
float cv_8 = seed.adc.GetFloat(8);
seed.PrintLine("cv_1: %f", cv_1);
seed.PrintLine("cv_2: %f", cv_2);
seed.PrintLine("cv_3: %f", cv_3);
seed.PrintLine("cv_4: %f", cv_4);
seed.PrintLine("cv_5: %f", cv_5);
seed.PrintLine("cv_6: %f", cv_6);
seed.PrintLine("cv_7: %f", cv_7);
seed.PrintLine("cv_8: %f", cv_8);
seed.PrintLine("\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment