Skip to content

Commit

Permalink
Kevin/bms/imd decoding fix (#1424)
Browse files Browse the repository at this point in the history
### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->
Changed the trigger source for tim1 from ti1fp2 to ti1fp1 since we
switched the channels 1 and 2 functionality from thruna to quadruna.
Also changed the user constants for the tim1 frequency to the value of
the clk config.

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->
Tested with function generator and oscilloscope to confirm readings were
accurate.
### Resolved Tickets
<!-- Link any tickets that this PR resolves. -->
FIRM-221
  • Loading branch information
KelmLelm authored Jan 14, 2025
1 parent ebe8275 commit c53d212
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 60 deletions.
85 changes: 41 additions & 44 deletions firmware/quadruna/BMS/src/cubemx/BMS.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -109,55 +109,54 @@ Mcu.Pin14=PC5
Mcu.Pin15=PB0
Mcu.Pin16=PB1
Mcu.Pin17=PE7
Mcu.Pin18=PE11
Mcu.Pin19=PB12
Mcu.Pin18=PB12
Mcu.Pin19=PB13
Mcu.Pin2=PH1-OSC_OUT
Mcu.Pin20=PB13
Mcu.Pin21=PB14
Mcu.Pin22=PB15
Mcu.Pin23=PD9
Mcu.Pin24=PD10
Mcu.Pin25=PD11
Mcu.Pin26=PD12
Mcu.Pin27=PD13
Mcu.Pin28=PC6
Mcu.Pin29=PC7
Mcu.Pin20=PB14
Mcu.Pin21=PB15
Mcu.Pin22=PD9
Mcu.Pin23=PD10
Mcu.Pin24=PD11
Mcu.Pin25=PD12
Mcu.Pin26=PD13
Mcu.Pin27=PC6
Mcu.Pin28=PC7
Mcu.Pin29=PC8
Mcu.Pin3=PC0
Mcu.Pin30=PC8
Mcu.Pin31=PC9
Mcu.Pin32=PA8
Mcu.Pin33=PA9
Mcu.Pin34=PA13(JTMS/SWDIO)
Mcu.Pin35=PA14(JT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Constants=TIM3_PRESCALER,8;ADC_FREQUENCY,1000;TIM1_AUTO_RELOAD_REG,0xFFFF;TIMx_FREQUENCY,512000000;IWDG_RESET_FREQUENCY,5;TASK1KHZ_STACK_SIZE,512;TIM1_FREQUENCY,512000000;TASK100HZ_STACK_SIZE,512;TASK1HZ_STACK_SIZE,512;IWDG_WINDOW_DISABLE_VALUE,4095;IWDG_PRESCALER,4;TASKCANRX_STACK_SIZE,512;TIM1_PWM_MIN_FREQUENCY,1;LSI_FREQUENCY,32000;TIM1_PRESCALER,(TIM1_FREQUENCY / TIM1_AUTO_RELOAD_REG / TIM1_PWM_MIN_FREQUENCY)
Mcu.UserConstants=TIM3_PRESCALER,8;ADC_FREQUENCY,1000;TIM1_AUTO_RELOAD_REG,0xFFFF;TIMx_FREQUENCY,512000000;IWDG_RESET_FREQUENCY,5;TASK1KHZ_STACK_SIZE,512;TIM1_FREQUENCY,256000000;TASK100HZ_STACK_SIZE,512;TASK1HZ_STACK_SIZE,512;IWDG_WINDOW_DISABLE_VALUE,4095;IWDG_PRESCALER,4;TASKCANRX_STACK_SIZE,512;TIM1_PWM_MIN_FREQUENCY,1;LSI_FREQUENCY,32000;TIM1_PRESCALER,(TIM1_FREQUENCY / TIM1_AUTO_RELOAD_REG / TIM1_PWM_MIN_FREQUENCY)
Mcu.UserName=STM32H733VGTx
MxCube.Version=6.9.2
MxDb.Version=DB.6.0.92
Expand Down Expand Up @@ -368,7 +367,6 @@ PD9.GPIOParameters=GPIO_Label
PD9.GPIO_Label=BMS_OK_3V3
PD9.Locked=true
PD9.Signal=GPIO_Output
PE11.Signal=S_TIM1_CH2
PE7.GPIOParameters=GPIO_Label
PE7.GPIO_Label=LED
PE7.Locked=true
Expand Down Expand Up @@ -506,9 +504,8 @@ SH.ADCx_INP9.ConfNb=1
SH.S_TIM15_CH2.0=TIM15_CH2,Input_Capture2_from_TI2
SH.S_TIM15_CH2.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,Input_Capture1_from_TI1
SH.S_TIM1_CH1.ConfNb=1
SH.S_TIM1_CH2.0=TIM1_CH2,TriggerSource_TI2FP2
SH.S_TIM1_CH2.ConfNb=1
SH.S_TIM1_CH1.1=TIM1_CH1,TriggerSource_TI1FP1
SH.S_TIM1_CH1.ConfNb=2
SH.SharedAnalog_PC1.0=ADC1_INN10
SH.SharedAnalog_PC1.1=ADC1_INP11,IN11-Single-Ended
SH.SharedAnalog_PC1.ConfNb=2
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/BMS/src/cubemx/BMS.ioc.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
71035ef834f592d578d0a91d7ab21a94
b0a5ba8fcc46cb0bb8846b7353b0c5d9
2 changes: 1 addition & 1 deletion firmware/quadruna/BMS/src/cubemx/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern "C"
#define TIMx_FREQUENCY 512000000
#define IWDG_RESET_FREQUENCY 5
#define TASK1KHZ_STACK_SIZE 512
#define TIM1_FREQUENCY 512000000
#define TIM1_FREQUENCY 256000000
#define TASK100HZ_STACK_SIZE 512
#define TASK1HZ_STACK_SIZE 512
#define IWDG_WINDOW_DISABLE_VALUE 4095
Expand Down
4 changes: 2 additions & 2 deletions firmware/quadruna/BMS/src/cubemx/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ static void MX_TIM1_Init(void)
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
sSlaveConfig.InputTrigger = TIM_TS_TI2FP2;
sSlaveConfig.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_FALLING;
sSlaveConfig.InputTrigger = TIM_TS_TI1FP1;
sSlaveConfig.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchro(&htim1, &sSlaveConfig) != HAL_OK)
{
Expand Down
12 changes: 0 additions & 12 deletions firmware/quadruna/BMS/src/cubemx/Src/stm32h7xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE();

__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM1 GPIO Configuration
PE11 ------> TIM1_CH2
PA8 ------> TIM1_CH1
*/
GPIO_InitStruct.Pin = GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
Expand Down Expand Up @@ -600,11 +591,8 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
__HAL_RCC_TIM1_CLK_DISABLE();

/**TIM1 GPIO Configuration
PE11 ------> TIM1_CH2
PA8 ------> TIM1_CH1
*/
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_11);

HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8);

/* TIM1 interrupt DeInit */
Expand Down

0 comments on commit c53d212

Please sign in to comment.