diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 18f1ed461..c3584f111 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -99,7 +99,11 @@ void CounterUpdate(uint8_t index) uint32_t steps = (current_cycle-last_cycle+100000)/(clockCyclesPerMicrosecond() * 10000); cycle_time = (current_cycle-last_cycle)/steps; #ifdef ESP8266 - analogWriteCCyPeriod(Pin(GPIO_PWM1, index), 5, cycle_time ); + pinMode(Pin(GPIO_PWM1, index), OUTPUT); + uint32_t high = (cycle_time * 5) / 1023; + uint32_t low = cycle_time - high; + // Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t + startWaveformClockCycles(Pin(GPIO_PWM1, index), high, low, 0, -1, 0, true); #else analogWrite(Pin(GPIO_PWM1, index), 5); #endif