Use frequency instead of pulse width - much better resolution at high freq.

This commit is contained in:
Hakan Bastedt
2024-01-02 23:55:32 +01:00
parent 2e8e938345
commit d4a83eae80

View File

@@ -122,7 +122,7 @@ void TimerStep_CB(void)
void makePulses(uint32_t period /* in usecs */, uint32_t pulses /* nr of pulses to do*/)
{
MyTim->setOverflow(period / pulses, MICROSEC_FORMAT);
MyTim->setOverflow(pulses*1000000/period, HERTZ_FORMAT);
MyTim->setCaptureCompare(4, 50, PERCENT_COMPARE_FORMAT); // 50 %
stepCount = 0;
stepPulses = pulses;