Using timers in Daisy seed?

Is there a way to directly use timers in Daisy seed, similarly to the way it can be done in Arduino?

Basically, the idea is instead of having an audio callback with a fixed frequency and deal with phase increment calculations, to have another timer being called every time a new sample is required. It would be trivial to change the oscillator/wavetable frequency by simply changing how often the timer fires.

Thoughts?

1 Like

Immediate thought: It sounds like a very interesting alternative approach, but rather ‘fundamentally different’, so unless you are very lucky and-or clever you wouldn’t be able to use the Daisy software anymore.

1 Like

funny I am wondering the exact same thing in regards to accessing timers.

sadly if you look in the daisyLib there are a LOT of todos still in regards to timers

** @todo Fix issues with realtime getters, and wrapping of the timer(s).
** - This very noticeable with default settings for the 16-bit counters.
**** @todo Other General purpose timers**
** @todo Non-internal clock sources
**** @todo Use of the four-tim channels per tim**
** ** - PWM, etc.**
** ** - InputCapture/OutputCompare, etc.**
** @todo HRTIM
**** @todo Advanced timers (TIM1/TIM8)**

There are lots of timers on the stm32 chip however I can only find reference to Tim2 being used overtly in the daisylib files. Without a list of which systems on the chip are using what drivers (a cube file would do it but the cube file in the repo is very old I believe) I dont know how to go about enabling different timers.

i actually made a separate thread about this last night

The place to start figuring out what is going on with the timers specific to the daisy is in LIBDAISY/PER/TIM.CPP and TIM.H and then you can compare that to the drivers in the repo for the stm32h7

maybe we can get some info from the Daisy Team about which ones could be enabled etc.

1 Like

I have been searching the last day for references to timers. Things like this in the daisy code make me think there are still unfinished areas in this regard
see below from the Led.CPP file

   // Once we have a slower timer set up:
    // Right now its too fast.

    //    dsy_gpio_write(&hw_pin_,
    //                   (dsy_tim_get_tick() & RESOLUTION_MAX) < pwm_thresh_ ? on_
    //                                                                       : off_);
}

1 Like

Ok i take back everything I said. There is a new PR which is being developed for the daisy that unless I am totally wrong would cover extra timers, and also hardware PWM (for leds but also for audio with a lpf etc) on some pins.

this is huge and you can find the link in the thread I started on Friday about timers etc. I am going to try to add these files to my own repo and start experimenting. but its great as some of the calls are calls I was missing like
__HAL_TIM_SET_COMPARE