Compare commits
8 Commits
75d1d78714
...
3ffad99284
Author | SHA1 | Date | |
---|---|---|---|
3ffad99284 | |||
273ad047bd | |||
91bc0b20c8 | |||
5a50e4ebcd | |||
20f2071cea | |||
2ace1dd04c | |||
e4566b0cee | |||
2d083f6318 |
1
AMS_Master_Code/.gitignore
vendored
1
AMS_Master_Code/.gitignore
vendored
@ -9,3 +9,4 @@ STM32Make.make
|
||||
openocd.cfg
|
||||
.stm32env
|
||||
!/.vscode/launch.json
|
||||
/.metadata/
|
83
AMS_Master_Code/1803-output_1712.txt
Normal file
83
AMS_Master_Code/1803-output_1712.txt
Normal file
@ -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] ---------------
|
48
AMS_Master_Code/1803-output_1759.txt
Normal file
48
AMS_Master_Code/1803-output_1759.txt
Normal file
@ -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
|
44
AMS_Master_Code/1803-output_1803.txt
Normal file
44
AMS_Master_Code/1803-output_1803.txt
Normal file
@ -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
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
||||
|
@ -42,6 +42,7 @@ HAL_StatusTypeDef amsCheckUnderOverVoltage(Cell_Module (*module)[N_BMS]);
|
||||
|
||||
HAL_StatusTypeDef amsClearFlag();
|
||||
HAL_StatusTypeDef amsClearAux();
|
||||
HAL_StatusTypeDef amsClearOVUV();
|
||||
|
||||
HAL_StatusTypeDef amsReadCellVoltages(Cell_Module (*module)[N_BMS]);
|
||||
|
||||
|
@ -31,6 +31,8 @@ HAL_StatusTypeDef amsReset() {
|
||||
amsWakeUp();
|
||||
readCMD(SRST, CMD_EMPTY_BUFFER, 0);
|
||||
|
||||
amsWakeUp();
|
||||
|
||||
uint8_t sidbuffer[CMD_BUFFER_SIZE(SID_GROUP_SIZE)] = {};
|
||||
if (readCMD(RDSID, sidbuffer, SID_GROUP_SIZE) != HAL_OK) {
|
||||
bool nonzero = false;
|
||||
@ -48,6 +50,8 @@ HAL_StatusTypeDef amsReset() {
|
||||
return HAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
debug_log(LOG_LEVEL_INFO, "BMS reset complete");
|
||||
|
||||
if (DEBUG_CHANNEL_ENABLED(LOG_LEVEL_INFO)) {
|
||||
@ -290,6 +294,11 @@ HAL_StatusTypeDef amsClearFlag() {
|
||||
|
||||
HAL_StatusTypeDef amsClearAux() { return writeCMD(CLRAUX, CMD_EMPTY_BUFFER, 0); }
|
||||
|
||||
HAL_StatusTypeDef amsClearOVUV() {
|
||||
uint8_t buffer[CMD_BUFFER_SIZE(6)] = {[0 ... CMD_BUFFER_SIZE(6) - 1] = 0xFF};
|
||||
return writeCMD(CLOVUV, buffer, 6);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef amsReadCellVoltages(Cell_Module (*module)[N_BMS]) {
|
||||
uint8_t rxbuffer[CMD_BUFFER_SIZE(CV_GROUP_A_SIZE)] = {};
|
||||
|
||||
|
@ -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
|
||||
@ -99,10 +99,12 @@ ADBMS_DetailedStatus AMS_Idle_Loop() {
|
||||
}
|
||||
|
||||
if ((match = any(module.overVoltage))) {
|
||||
amsClearOVUV();
|
||||
return (ADBMS_DetailedStatus){ADBMS_OVERVOLT, match - 1};
|
||||
}
|
||||
|
||||
if ((match = any(module.underVoltage))) {
|
||||
amsClearOVUV();
|
||||
return (ADBMS_DetailedStatus){ADBMS_UNDERVOLT, match - 1};
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,8 @@ static uint8_t checkCommandPEC(uint8_t* data, uint8_t datalen) {
|
||||
static uint16_t computeCRC10(const uint8_t* data, size_t length, bool rx_cmd) {
|
||||
uint16_t remainder = INITIAL_DATA_PEC;
|
||||
const uint16_t poly = 0x8F;
|
||||
size_t limit = length;
|
||||
|
||||
if (rx_cmd && (length > 0)) {
|
||||
limit = length - 1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < limit; i++) {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
remainder ^= (uint16_t)(data[i] << 2);
|
||||
for (int b = 0; b < 8; b++) {
|
||||
if (remainder & 0x200) {
|
||||
@ -100,9 +95,9 @@ static uint16_t computeCRC10(const uint8_t* data, size_t length, bool rx_cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
// If receiving a command, handle leftover bits
|
||||
if (rx_cmd && (length > 0)) {
|
||||
remainder ^= (uint16_t)((data[length - 1] & 0xFC) << 2);
|
||||
// Handle last bits of the last byte if rx_cmd is true
|
||||
if (rx_cmd) {
|
||||
remainder ^= (uint16_t)((data[length] & 0xFC) << 2);
|
||||
for (int b = 0; b < 6; b++) {
|
||||
if (remainder & 0x200) {
|
||||
remainder = (uint16_t)((remainder << 1) ^ poly);
|
||||
@ -188,6 +183,8 @@ HAL_StatusTypeDef ___writeCMD(uint16_t command, uint8_t * args, size_t arglen) {
|
||||
calculateCommandPEC(args, 4);
|
||||
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
args[BUFFER_BMS_OFFSET(i, arglen) + arglen] = 0; // zero out the PEC
|
||||
args[BUFFER_BMS_OFFSET(i, arglen) + arglen + 1] = 0;
|
||||
calculateDataPEC(&args[4 + (i * (arglen + 2))], arglen + 2); //DPEC is calculated over the data, not the command, and placed at the end of the data
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
@ -114,14 +114,23 @@ int main(void)
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
int count = 0;
|
||||
int error_count = 0;
|
||||
while (1)
|
||||
{
|
||||
if (error_count > 25) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Too many errors, restarting BMS...");
|
||||
status = AMS_Init(&hspi1);
|
||||
if (status.status != ADBMS_NO_ERROR) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Failed to initialize BMS, AMS_Init returned %u (%s) on BMS %d", status.status, ADBMS_Status_ToString(status.status), status.bms_id);
|
||||
HAL_Delay(2000);
|
||||
continue;
|
||||
}
|
||||
error_count = 0;
|
||||
}
|
||||
status = AMS_Idle_Loop();
|
||||
if (status.status != ADBMS_NO_ERROR) {
|
||||
debug_log(LOG_LEVEL_ERROR, "AMS_Idle_Loop returned %u (%s) on BMS %d", status.status, ADBMS_Status_ToString(status.status), status.bms_id);
|
||||
HAL_Delay(2000);
|
||||
AMS_Init(&hspi1);
|
||||
continue;
|
||||
error_count++;
|
||||
}
|
||||
if (count % 4 == 0) {
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
@ -331,7 +340,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 +385,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 +399,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 +414,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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
##########################################################################################################################
|
||||
# File automatically-generated by tool: [projectgenerator] version: [4.5.0-RC5] date: [Thu Feb 20 01:39:39 CET 2025]
|
||||
# File automatically-generated by tool: [projectgenerator] version: [4.6.0-B36] date: [Tue Mar 18 20:15:25 CET 2025]
|
||||
##########################################################################################################################
|
||||
|
||||
# ------------------------------------------------
|
||||
@ -145,7 +145,7 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
||||
# LDFLAGS
|
||||
#######################################
|
||||
# link script
|
||||
LDSCRIPT = stm32h7a3zitxq_flash.ld
|
||||
LDSCRIPT = STM32H7A3XX_FLASH.ld
|
||||
|
||||
# libraries
|
||||
LIBS = -lc -lm -lnosys
|
||||
|
@ -24,9 +24,9 @@ cDefinitions:
|
||||
- STM32H7
|
||||
- USE_HAL_DRIVER
|
||||
- FTCAN_NUM_FILTERS=32
|
||||
- COMMIT_HASH='"$(shell git describe --always --dirty --abbrev=8)"'
|
||||
- COMMIT_BRANCH='"$(shell git rev-parse --abbrev-ref HEAD)"'
|
||||
- COMPILE_DATE='"$(shell date +'%Y-%m-%d %H:%M:%S')"'
|
||||
- COMMIT_HASH='"$(shell git describe --always --dirty --abbrev=8 2>/dev/null || echo unknown)"'
|
||||
- COMMIT_BRANCH='"$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"'
|
||||
- COMPILE_DATE='"$(shell date "+%Y-%m-%d %H:%M:%S")"'
|
||||
|
||||
cxxDefinitions: []
|
||||
asDefinitions: []
|
||||
|
209
AMS_Master_Code/STM32H7A3XX_FLASH.ld
Normal file
209
AMS_Master_Code/STM32H7A3XX_FLASH.ld
Normal file
@ -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
|
||||
**
|
||||
** <h2><center>© COPYRIGHT(c) 2025 STMicroelectronics</center></h2>
|
||||
**
|
||||
** 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 ( * )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user