From e4566b0cee5cd90bbd34631485c3a0061f387c98 Mon Sep 17 00:00:00 2001 From: kbracher Date: Tue, 25 Mar 2025 19:26:25 +0100 Subject: [PATCH] fix: use correct CS gpio, set correct number of cells + other changes for testing --- AMS_Master_Code/1803-output_1712.txt | 83 +++++++ AMS_Master_Code/1803-output_1759.txt | 48 ++++ AMS_Master_Code/1803-output_1803.txt | 44 ++++ AMS_Master_Code/AMS Master Nucleo.ioc | 25 ++- AMS_Master_Code/Core/Inc/config_ADBMS6830.h | 2 +- AMS_Master_Code/Core/Inc/main.h | 4 +- .../Core/Src/ADBMS_HighLevel.c | 2 +- AMS_Master_Code/Core/Src/main.c | 24 +- AMS_Master_Code/STM32H7A3XX_FLASH.ld | 209 ++++++++++++++++++ 9 files changed, 413 insertions(+), 28 deletions(-) create mode 100644 AMS_Master_Code/1803-output_1712.txt create mode 100644 AMS_Master_Code/1803-output_1759.txt create mode 100644 AMS_Master_Code/1803-output_1803.txt create mode 100644 AMS_Master_Code/STM32H7A3XX_FLASH.ld diff --git a/AMS_Master_Code/1803-output_1712.txt b/AMS_Master_Code/1803-output_1712.txt new file mode 100644 index 0000000..9a4c9ca --- /dev/null +++ b/AMS_Master_Code/1803-output_1712.txt @@ -0,0 +1,83 @@ +[INFO] AMS_Master on nucleo-test (6fa720c4-dirty), compiled at 2025-03-18 16:46:15 +[INFO] Starting BMS... +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:98@amsAuxAndStatusMeasurement: readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:296@amsReadCellVoltages: readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:263@amsCheckUnderOverVoltage: readCMD(RDSTATD, regbuffer, STATUS_GROUP_D_SIZE) failed with status 2 (HAL_BUSY) +[INFO] Module 0 status: +[INFO] Cell voltages (mV): +[INFO] C0: 0 C1: 0 C2: 0 C3: 0 +[INFO] C4: 0 C5: 0 C6: 0 C7: 0 +[INFO] C8: 0 C9: 0 C10: 0 C11: 0 +[INFO] C12: 0 C13: 0 C14: 0 C15: 0 +[INFO] GPIO values: +[INFO] G0: 0 G1: 0 G2: 0 G3: 0 G4: 0 +[INFO] G5: 0 G6: 0 G7: 0 G8: 0 G9: 0 +[INFO] Internal temp: 0, VAnalog: 0, VDigital: 0, VRef: 0 +[INFO] Status flags: [none] +[INFO] Conversion counter: 0 +[INFO] --------------- +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:98@amsAuxAndStatusMeasurement: readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:296@amsReadCellVoltages: readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:263@amsCheckUnderOverVoltage: readCMD(RDSTATD, regbuffer, STATUS_GROUP_D_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:98@amsAuxAndStatusMeasurement: readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:296@amsReadCellVoltages: readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:263@amsCheckUnderOverVoltage: readCMD(RDSTATD, regbuffer, STATUS_GROUP_D_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:98@amsAuxAndStatusMeasurement: readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:296@amsReadCellVoltages: readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:263@amsCheckUnderOverVoltage: readCMD(RDSTATD, regbuffer, STATUS_GROUP_D_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:98@amsAuxAndStatusMeasurement: readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:296@amsReadCellVoltages: readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE) failed with status 2 (HAL_BUSY) +[ERROR] STM32 SPI HAL returned error HAL_BUSY +[ERROR] SPI error bits: MODF OVR DMA ABORT UDR NOT_SUPPORTED +[ERROR] in ADBMS_Abstraction.c:263@amsCheckUnderOverVoltage: readCMD(RDSTATD, regbuffer, STATUS_GROUP_D_SIZE) failed with status 2 (HAL_BUSY) +[INFO] Module 0 status: +[INFO] Cell voltages (mV): +[INFO] C0: 0 C1: 0 C2: 0 C3: 0 +[INFO] C4: 0 C5: 0 C6: 0 C7: 0 +[INFO] C8: 0 C9: 0 C10: 0 C11: 0 +[INFO] C12: 0 C13: 0 C14: 0 C15: 0 +[INFO] GPIO values: +[INFO] G0: 0 G1: 0 G2: 0 G3: 0 G4: 0 +[INFO] G5: 0 G6: 0 G7: 0 G8: 0 G9: 0 +[INFO] Internal temp: 0, VAnalog: 0, VDigital: 0, VRef: 0 +[INFO] Status flags: [none] +[INFO] Conversion counter: 0 +[INFO] --------------- \ No newline at end of file diff --git a/AMS_Master_Code/1803-output_1759.txt b/AMS_Master_Code/1803-output_1759.txt new file mode 100644 index 0000000..ae5614c --- /dev/null +++ b/AMS_Master_Code/1803-output_1759.txt @@ -0,0 +1,48 @@ +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 \ No newline at end of file diff --git a/AMS_Master_Code/1803-output_1803.txt b/AMS_Master_Code/1803-output_1803.txt new file mode 100644 index 0000000..d90279f --- /dev/null +++ b/AMS_Master_Code/1803-output_1803.txt @@ -0,0 +1,44 @@ +[INFO] AMS_Master on nucleo-test (6fa720c4-dirty), compiled at 2025-03-18 18:02:39 +[INFO] Starting BMS... +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 2 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 2 R | 00 27 +[NOISY] 2 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 2006 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 2006 R | 00 27 +[NOISY] 2006 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 4010 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 4010 R | 00 27 +[NOISY] 4010 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 6014 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 6014 R | 00 27 +[NOISY] 6014 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 8018 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 8018 R | 00 27 +[NOISY] 8018 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 +[INFO] ADBMS6830B HAL - configured for 1 controllers and 16 cells per controller... +[NOISY] 10022 R | 00 02 0: FF FF FF FF FF FF +[NOISY] 10022 R | 00 27 +[NOISY] 10022 R | 00 2C 0: FF +[ERROR] CRC failure when reading BMS IDs, but some IDs are nonzero. --- Intermittent connection? +[ERROR] ADBMS6830B HAL - initialization failed +[ERROR] Failed to initialize BMS, AMS_Init returned 9 (ADBMS_INTERNAL_BMS_FAULT) on BMS -1 \ No newline at end of file diff --git a/AMS_Master_Code/AMS Master Nucleo.ioc b/AMS_Master_Code/AMS Master Nucleo.ioc index 9b7fa4c..d04e120 100644 --- a/AMS_Master_Code/AMS Master Nucleo.ioc +++ b/AMS_Master_Code/AMS Master Nucleo.ioc @@ -62,9 +62,9 @@ Mcu.Name=STM32H7A3Z(G-I)TxQ Mcu.Package=LQFP144 Mcu.Pin0=PC13 Mcu.Pin1=PC14-OSC32_IN -Mcu.Pin10=PB14 -Mcu.Pin11=PD8 -Mcu.Pin12=PD9 +Mcu.Pin10=PD8 +Mcu.Pin11=PD9 +Mcu.Pin12=PD14 Mcu.Pin13=PA13 Mcu.Pin14=PA14 Mcu.Pin15=PB3 @@ -74,11 +74,11 @@ Mcu.Pin18=VP_MEMORYMAP_VS_MEMORYMAP Mcu.Pin2=PC15-OSC32_OUT Mcu.Pin3=PH0-OSC_IN Mcu.Pin4=PH1-OSC_OUT -Mcu.Pin5=PA4 -Mcu.Pin6=PA5 -Mcu.Pin7=PA6 -Mcu.Pin8=PA7 -Mcu.Pin9=PB0 +Mcu.Pin5=PA5 +Mcu.Pin6=PA6 +Mcu.Pin7=PA7 +Mcu.Pin8=PB0 +Mcu.Pin9=PB14 Mcu.PinsNb=19 Mcu.ThirdPartyNb=0 Mcu.UserConstants= @@ -100,10 +100,6 @@ PA13.Mode=Trace_Asynchronous_SW PA13.Signal=DEBUG_JTMS-SWDIO PA14.Mode=Trace_Asynchronous_SW PA14.Signal=DEBUG_JTCK-SWCLK -PA4.GPIOParameters=GPIO_Label -PA4.GPIO_Label=AMS_CS -PA4.Locked=true -PA4.Signal=GPIO_Output PA5.Mode=Full_Duplex_Master PA5.Signal=SPI1_SCK PA6.Mode=Full_Duplex_Master @@ -132,6 +128,10 @@ PC15-OSC32_OUT.GPIOParameters=GPIO_Label PC15-OSC32_OUT.GPIO_Label=OSC32_OUT PC15-OSC32_OUT.Locked=true PC15-OSC32_OUT.Signal=RCC_OSC32_OUT +PD14.GPIOParameters=GPIO_Label +PD14.GPIO_Label=AMS_CS +PD14.Locked=true +PD14.Signal=GPIO_Output PD8.GPIOParameters=GPIO_Label PD8.GPIO_Label=STLINK_RX PD8.Locked=true @@ -155,6 +155,7 @@ PH1-OSC_OUT.Signal=RCC_OSC_OUT PinOutPanel.RotationAngle=0 ProjectManager.AskForMigrate=true ProjectManager.BackupPrevious=false +ProjectManager.CompilerLinker=GCC ProjectManager.CompilerOptimize=6 ProjectManager.ComputerToolchain=false ProjectManager.CoupleFile=false diff --git a/AMS_Master_Code/Core/Inc/config_ADBMS6830.h b/AMS_Master_Code/Core/Inc/config_ADBMS6830.h index 7813fd3..4b60e4c 100644 --- a/AMS_Master_Code/Core/Inc/config_ADBMS6830.h +++ b/AMS_Master_Code/Core/Inc/config_ADBMS6830.h @@ -3,7 +3,7 @@ #define __CONFIG_ADBMS6830_H #include "main.h" -#define N_BMS 2 +#define N_BMS 1 #define ADBMS_SPI_TIMEOUT 100 // Timeout in ms [[maybe_unused]] static inline void mcuAdbmsCSLow() { diff --git a/AMS_Master_Code/Core/Inc/main.h b/AMS_Master_Code/Core/Inc/main.h index 326e347..4bbf58a 100644 --- a/AMS_Master_Code/Core/Inc/main.h +++ b/AMS_Master_Code/Core/Inc/main.h @@ -67,8 +67,6 @@ void Error_Handler(void); #define PH0_MCU_GPIO_Port GPIOH #define PH1_MCU_Pin GPIO_PIN_1 #define PH1_MCU_GPIO_Port GPIOH -#define AMS_CS_Pin GPIO_PIN_4 -#define AMS_CS_GPIO_Port GPIOA #define LD1_Pin GPIO_PIN_0 #define LD1_GPIO_Port GPIOB #define LD3_Pin GPIO_PIN_14 @@ -77,6 +75,8 @@ void Error_Handler(void); #define STLINK_RX_GPIO_Port GPIOD #define STLINK_TX_Pin GPIO_PIN_9 #define STLINK_TX_GPIO_Port GPIOD +#define AMS_CS_Pin GPIO_PIN_14 +#define AMS_CS_GPIO_Port GPIOD #define LD2_Pin GPIO_PIN_1 #define LD2_GPIO_Port GPIOE diff --git a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c index 35b9bd1..efbe485 100644 --- a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c +++ b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c @@ -20,7 +20,7 @@ Cell_Module modules[N_BMS] = {}; uint32_t balancedCells = 0; bool balancingActive = false; -uint8_t numberofCells = 15; +uint8_t numberofCells = 16; uint8_t packetChecksumFails = 0; #define MAX_PACKET_CHECKSUM_FAILS 5 diff --git a/AMS_Master_Code/Core/Src/main.c b/AMS_Master_Code/Core/Src/main.c index 72dc366..1e46e69 100644 --- a/AMS_Master_Code/Core/Src/main.c +++ b/AMS_Master_Code/Core/Src/main.c @@ -61,7 +61,7 @@ static void MX_SPI1_Init(void); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ -uint32_t volatile logging_mask = 0b11111; // no LOG_LEVEL_NOISY +uint32_t volatile logging_mask = 0b111111; // no LOG_LEVEL_NOISY /* USER CODE END 0 */ /** @@ -101,7 +101,7 @@ int main(void) debug_clear_console(); debug_log(LOG_LEVEL_INFO, "AMS_Master on %s (%s), compiled at %s", COMMIT_BRANCH, COMMIT_HASH, COMPILE_DATE); debug_log(LOG_LEVEL_INFO, "Starting BMS..."); - ADBMS_DetailedStatus status = {}; + ADBMS_DetailedStatus status = {ADBMS_INTERNAL_BMS_FAULT, -1}; while (status.status != ADBMS_NO_ERROR) { status = AMS_Init(&hspi1); if (status.status != ADBMS_NO_ERROR) { @@ -331,7 +331,7 @@ static void MX_SPI1_Init(void) hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLE; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; @@ -376,10 +376,10 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOE_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(AMS_CS_GPIO_Port, AMS_CS_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(AMS_CS_GPIO_Port, AMS_CS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); @@ -390,13 +390,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : AMS_CS_Pin */ - GPIO_InitStruct.Pin = AMS_CS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(AMS_CS_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : LD1_Pin LD3_Pin */ GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -412,6 +405,13 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Alternate = GPIO_AF7_USART3; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + /*Configure GPIO pin : AMS_CS_Pin */ + GPIO_InitStruct.Pin = AMS_CS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(AMS_CS_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; diff --git a/AMS_Master_Code/STM32H7A3XX_FLASH.ld b/AMS_Master_Code/STM32H7A3XX_FLASH.ld new file mode 100644 index 0000000..d502823 --- /dev/null +++ b/AMS_Master_Code/STM32H7A3XX_FLASH.ld @@ -0,0 +1,209 @@ +/* +****************************************************************************** +** + +** File : LinkerScript.ld +** +** Author : STM32CubeMX +** +** Abstract : Linker script for STM32H7A3ZITxQ series +** 2048Kbytes FLASH and 1216Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed “as is,” without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2025 STMicroelectronics

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of STMicroelectronics nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 1024K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >DTCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >DTCMRAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >DTCMRAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + +} + +