@@ -37,6 +37,7 @@ void setupMozziADC(int8_t speed) {
3737
3838
3939
40+
4041// // BEGIN AUDIO OUTPUT code ///////
4142#include < driver/i2s.h> // for I2S-based output modes
4243#include < driver/timer.h> // for EXTERNAL_AUDIO_OUTPUT
@@ -103,17 +104,19 @@ void CACHED_FUNCTION_ATTR timer0_audio_output_isr(void *) {
103104static void startAudio () {
104105#if (BYPASS_MOZZI_OUTPUT_BUFFER != true) // for external audio output, set up a timer running a audio rate
105106 static intr_handle_t s_timer_handle;
107+ const int div = 2 ;
106108 timer_config_t config = {
107- .alarm_en = true ,
108- .counter_en = false ,
109- .intr_type = TIMER_INTR_LEVEL,
109+ .alarm_en = ( timer_alarm_t ) true ,
110+ .counter_en = ( timer_start_t ) false ,
111+ .intr_type = ( timer_intr_mode_t ) TIMER_INTR_LEVEL,
110112 .counter_dir = TIMER_COUNT_UP,
111- .auto_reload = true ,
112- .divider = 1 // For max available precision: The APB_CLK clock signal is running at 80 MHz, i.e. 1/80 uS per tick
113+ .auto_reload = (timer_autoreload_t ) true ,
114+ .divider = div // For max available precision: The APB_CLK clock signal is running at 80 MHz, i.e. 2/80 uS per tick
115+ // Min acceptable value is 2
113116 };
114117 timer_init (TIMER_GROUP_0, TIMER_0, &config);
115118 timer_set_counter_value (TIMER_GROUP_0, TIMER_0, 0 );
116- timer_set_alarm_value (TIMER_GROUP_0, TIMER_0, 80000000UL / AUDIO_RATE);
119+ timer_set_alarm_value (TIMER_GROUP_0, TIMER_0, 80000000UL / AUDIO_RATE / div );
117120 timer_enable_intr (TIMER_GROUP_0, TIMER_0);
118121 timer_isr_register (TIMER_GROUP_0, TIMER_0, &timer0_audio_output_isr, nullptr , 0 , &s_timer_handle);
119122 timer_start (TIMER_GROUP_0, TIMER_0);
0 commit comments