STM32CubeIDE project template

Hi,

I have just received my Daisy Seed. I’m very new to STM32, but I used to use NXP MCUXPresso.
I have started a project template for Daisy, using STM32CubeIDE (https://github.com/ThomArmax/DaisyTemplate)

What I did is:

  • import project from existing ioc file
  • remove all HAL sources
  • add libdaisy and DaisySp as submodules
  • add a build script to build the libs (copied from DaisyExample repository)
  • create a dummy project, configured to link daisy’s libs and use libdaisy’s linker script

The goal is to have a ready project for STM32CubeIDE, you only have to download, then start to code, without any configuration. Feel free if you have any question, remarks or recommendation :slight_smile:

This is working and I’m able to debug using JLink Edu Mini :

Cheer :wink:

2 Likes

There are some differences between clocks used in libDaisy and in this CubeMX project. It shouldn’t matter if used as intended (as libDaisy would be configuring clocks on its own), but anyone using just project file export and not libDaisy should double check them. That said, I haven’t noticed anything that would look like it should create problems.

Ok, thanks. I didn’t notices that, I’ll check.

The difference that I’ve noticed:

  1. currently Daisy is clocked at 400Mhz - but that’s just leftover from older MCU revision and they plan to update libDaisy to use full 480Mhz clock. I have been using this higher clock for a week or so and haven’t noticed any issues. As it should be as it’s standard clock for currently used MCU chip revision.

  2. I think that some peripherals are clocked higher in libDaisy (QSPI, FMC). This should be double checked by looking at current libDaisy source, but could be minor performance upgrade for anyone using this Cube project and not libDaisy

@antisvin I can’t get the ADC working, could that be the cause ?

If you’re using this project just to generate a patch template, it shouldn’t matter what you’re setting in Cube project. So no, ADC functionality shouldn’t be affected by this.

I may have missed something then :smiley:

freqModifier is always 0.999984741

if it get uint16_t value, always 65535

Pot 100K
pot1 -> 21 (3.3 analog)
pot2 -> 22 (ADC0)
pot3 -> 20 (AGND)

Code :

#include "daisysp.h"
#include "daisy_seed.h"

using namespace daisysp;
using namespace daisy;

#define OSC_COUNT 4

static DaisySeed  seed;
static Oscillator osc[OSC_COUNT];
static Parameter freqParam;

const float baseFreq = 440.0;

//AdcChannelConfig adc[1]; //array size for number of ADC channels you need

static void AudioCallback(float *in, float *out, size_t size)
{
    float sig;
    float freqModifier = seed.adc.GetFloat(0);

    for(size_t i = 0; i < size; i += 2)
    {
    	sig = 0;
    	for (size_t j = 0; j < OSC_COUNT; j++)
    	{
            sig += osc[j].Process();
    	}
    	out[i] = sig;// left out
    	out[i + 1] = sig; // right out
    }
}

int main(void)
{
    // initialize seed hardware and oscillator daisysp module
    float sample_rate;
    seed.Configure();
    seed.Init();
    sample_rate = seed.AudioSampleRate();

    for (int i = 0; i < OSC_COUNT; i++)
    {
    	osc[i].Init(sample_rate);
    	// Set parameters for oscillator
    	osc[i].SetWaveform(Oscillator::WAVE_SAW);
    	osc[i].SetFreq(baseFreq + i*5);
    	osc[i].SetAmp(0.5);
    }

    //This is our ADC configuration
    AdcChannelConfig adc;
    //Configure pin 15 as an ADC input. This is where we'll read the knob.
    adc.InitSingle(seed.GetPin(15));

    //Initialize the adc with the config we just made
    seed.adc.Init(&adc, 1);
    //Start reading values
    seed.adc.Start();

    // start callback
    seed.StartAudio(AudioCallback);

    while(1) { }
}