switched to 0.1ms internal clock resolution. this fixes higher than 193bpm glitch, but needs testing

This commit is contained in:
Oleksiy
2024-08-04 17:01:37 +03:00
parent 01806cbd82
commit f5b1dbf122

View File

@ -6,12 +6,12 @@
#include <avr/wdt.h>
#include <NeoHWSerial.h>
#define VERSION "V:1.1.1"
#define VERSION "V:1.1.1b"
byte memCode = 'D'; //Change to different letter if you changed the data structure
#define PPQN 24
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
#define MINBPM 20
@ -222,7 +222,7 @@ void setup() {
resetClocks();
FlexiTimer2::set(1, 1.0 / 1000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking
FlexiTimer2::set(1, 1.0 / 10000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking
FlexiTimer2::start();
}
@ -524,7 +524,7 @@ void calculateBPMTiming() {
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
}
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
pulsePeriod = 600000 / ((bpm + mod) * PPQN);
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock (hardcoded)
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6;