Skip to content

Commit

Permalink
no locking up in cnt freq mode
Browse files Browse the repository at this point in the history
  • Loading branch information
H3wastooshort committed Jul 14, 2024
1 parent 655ed41 commit 98b0407
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions firmware/BikeUSBv2/ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ void AC_loop_counter() {
if (!AC_pw_method) {
uint32_t time_passed = millis() - last_AC_counter_calc;
if (time_passed > AC_counter_interval) {
if (millis() - last_AC_interrupt > MAX_PW_FOR_CNT_METHOD) AC_pw_method = true; //don't lock up in cnt mode

float timebase = float(time_passed) / 1000.0;
AC_frequency = AC_counter / timebase;

printDebug(DBG_AC, AC_counter);
printDebug(DBG_AC, time_passed);

Expand All @@ -65,7 +67,7 @@ void AC_loop_counter() {
//Interrupt
void AC_interrupt() {
AC_counter++;

uint32_t pulsewidth = millis() - last_AC_interrupt;
last_AC_interrupt = millis();
//printDebug(DBG_AC, pulsewidth);
Expand Down

0 comments on commit 98b0407

Please sign in to comment.