From e6c32f441749673a2c39712437b5b4500f004d60 Mon Sep 17 00:00:00 2001 From: Markus Herb Date: Thu, 25 Feb 2016 20:48:17 +0100 Subject: [PATCH] Fix Hallsensor reverse phase mapping --- mcpwm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mcpwm.c b/mcpwm.c index a05e379d..396c5006 100644 --- a/mcpwm.c +++ b/mcpwm.c @@ -494,7 +494,7 @@ void mcpwm_set_configuration(volatile mc_configuration *configuration) { * The commutations corresponding to the hall sensor states in the forward direction- */ void mcpwm_init_hall_table(int8_t *table) { - const int fwd_to_rev[7] = {-1,4,3,2,1,6,5}; + const int fwd_to_rev[7] = {-1,1,6,5,4,3,2}; for (int i = 0;i < 8;i++) { hall_to_phase_table[8 + i] = table[i]; @@ -505,13 +505,7 @@ void mcpwm_init_hall_table(int8_t *table) { continue; } - ind_now += 2; - if (ind_now > 6) { - ind_now -= 6; - } - ind_now = fwd_to_rev[ind_now]; - - hall_to_phase_table[i] = ind_now; + hall_to_phase_table[i] = fwd_to_rev[ind_now]; } }