diff --git a/BLDC_E54/.gitignore b/BLDC_E54/.gitignore
new file mode 100644
index 0000000..fe57f80
--- /dev/null
+++ b/BLDC_E54/.gitignore
@@ -0,0 +1,23 @@
+
+## Ignore Atmel Studio temporary files and build results
+# https://www.microchip.com/mplab/avr-support/atmel-studio-7
+
+# Atmel Studio is powered by an older version of Visual Studio,
+# so most of the project and solution files are the same as VS files,
+# only prefixed by an `at`.
+
+#Build Directories
+[Dd]ebug/
+[Rr]elease/
+
+#Build Results
+*.o
+*.d
+*.eep
+*.elf
+*.hex
+*.map
+*.srec
+
+#User Specific Files
+*.atsuo
diff --git a/BLDC_E54/.vs/BLDC_E54/v14/.atsuo b/BLDC_E54/.vs/BLDC_E54/v14/.atsuo
index b13348b..2604932 100644
Binary files a/BLDC_E54/.vs/BLDC_E54/v14/.atsuo and b/BLDC_E54/.vs/BLDC_E54/v14/.atsuo differ
diff --git a/BLDC_E54/BLDC_E54/BLDC_E54.cproj b/BLDC_E54/BLDC_E54/BLDC_E54.cproj
index ea25ccf..0f61d09 100644
--- a/BLDC_E54/BLDC_E54/BLDC_E54.cproj
+++ b/BLDC_E54/BLDC_E54/BLDC_E54.cproj
@@ -1011,6 +1011,9 @@
compile
+
+ compile
+
compile
diff --git a/BLDC_E54/BLDC_E54/bldc.c b/BLDC_E54/BLDC_E54/bldc.c
index aac6c4f..fb7b0eb 100644
--- a/BLDC_E54/BLDC_E54/bldc.c
+++ b/BLDC_E54/BLDC_E54/bldc.c
@@ -79,7 +79,7 @@ void BLDC_init(BLDCMotor_t *motor)
motor->VdcBus_pu = DEVICE_DC_VOLTAGE_V;
motor->VoneByDcBus_pu = 1.0f/DEVICE_DC_VOLTAGE_V;
- motor->motor_commutation_Pattern = COMMUTATION_PATTERN;
+ motor->motor_commutation_Pattern = COMMUTATION_PATTERN_M1;
motor->desired_torque = 0.0;
motor->desired_speed = 0;
@@ -225,7 +225,7 @@ void exec_commutation(void)
//}
- TCC1->PATTBUF.reg = COMMUTATION_PATTERN[(Motor1.currentHallPattern + Motor1.directionOffset)];
+ TCC1->PATTBUF.reg = COMMUTATION_PATTERN_M1[(Motor1.currentHallPattern + Motor1.directionOffset)];
TCC1->CCBUF->reg = (uint16_t)Motor1.duty_cycle;
//hri_tcc_write_PATTBUF_reg(TCC1, (COMMUTATION_PATTERN[(Motor1.currentHallPattern + Motor1.directionOffset)]));
diff --git a/BLDC_E54/BLDC_E54/bldc.h b/BLDC_E54/BLDC_E54/bldc.h
index a96e409..3d91c2d 100644
--- a/BLDC_E54/BLDC_E54/bldc.h
+++ b/BLDC_E54/BLDC_E54/bldc.h
@@ -1,234 +1,157 @@
-/*
- * bldc.h
- *
- * Created: 10/03/2021 14:38:14
- * Author: Nick-XMG
- */
-
-#ifndef BLDC_H_
-#define BLDC_H_
-
-// ----------------------------------------------------------------------
-// header files
-// ----------------------------------------------------------------------
-#include "arm_math.h"
-#include "atmel_start.h"
-#include "control.h"
-
-
-// ----------------------------------------------------------------------
-// Current Sensor
-// ----------------------------------------------------------------------
-
-#define DRV_ISEN_A_CH ADC_INPUTCTRL_MUXPOS_AIN2_Val
-#define DRV_ISEN_B_CH ADC_INPUTCTRL_MUXPOS_AIN1_Val
-
-// ----------------------------------------------------------------------
-// Hall Parameters
-// ----------------------------------------------------------------------
-
-#define HALL_A_PIN GPIO(GPIO_PORTA, 6)
#define HALL_A_PORT PORT_PA06
#define HALL_A_MASK ~(1<<2)
#define HALL_A_LSR HALL_A_PIN - HALL_A_GROUP*32 -2
-#define HALL_A_GROUP HALL_A_PIN/32
#define HALL_B_PIN GPIO(GPIO_PORTA, 5)
-#define HALL_B_PORT PORT_PA05
-#define HALL_B_MASK ~(1<<1)
-#define HALL_B_LSR HALL_B_PIN - HALL_B_GROUP*32 -1
-#define HALL_B_GROUP HALL_B_PIN/32
-
-#define HALL_C_PIN GPIO(GPIO_PORTA, 4)
-#define HALL_C_PORT PORT_PA04
-#define HALL_C_MASK ~(1<<0)
-#define HALL_C_LSR HALL_C_PIN - HALL_C_GROUP*32 -0
-#define HALL_C_GROUP HALL_C_PIN/32
-
-/* if the Hall sensor reads 0x0 or 0x7 that means either one of the hall sensor is damaged or disconnected*/
-#define INVALID_HALL_0 (0U)
-#define INVALID_HALL_7 (7U)
-
-// ----------------------------------------------------------------------
-// ADC Parameters
-// ----------------------------------------------------------------------
-#define ADC_VOLTAGE_REFERENCE (3.3f)
-#define ADC_RESOLUTION (12)
-#define ADC_MAX_COUNTS (1<