From 50d1ffe353df67b63f8a4cdfa374391943ac0adc Mon Sep 17 00:00:00 2001 From: Dylan Donahue Date: Sun, 18 Feb 2024 18:48:46 -0500 Subject: [PATCH] added last timer --- Core/Src/main.c | 4 ++++ Core/Src/stm32f4xx_hal_msp.c | 25 +++---------------------- shepherd2.ioc | 7 ++++--- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 83559d2..25cf0bd 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -593,6 +593,10 @@ static void MX_TIM1_Init(void) { Error_Handler(); } + if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) + { + Error_Handler(); + } sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; diff --git a/Core/Src/stm32f4xx_hal_msp.c b/Core/Src/stm32f4xx_hal_msp.c index 98f750d..a5f4cd8 100644 --- a/Core/Src/stm32f4xx_hal_msp.c +++ b/Core/Src/stm32f4xx_hal_msp.c @@ -442,7 +442,6 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; if(htim_base->Instance==TIM1) { /* USER CODE BEGIN TIM1_MspInit 0 */ @@ -450,18 +449,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_TIM1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM1 GPIO Configuration - PA10 ------> TIM1_CH3 - */ - GPIO_InitStruct.Pin = Fan_PWMA10_Pin; - 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(Fan_PWMA10_GPIO_Port, &GPIO_InitStruct); - /* USER CODE BEGIN TIM1_MspInit 1 */ /* USER CODE END TIM1_MspInit 1 */ @@ -502,13 +489,14 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) __HAL_RCC_GPIOA_CLK_ENABLE(); /**TIM1 GPIO Configuration PA8 ------> TIM1_CH1 + PA10 ------> TIM1_CH3 */ - GPIO_InitStruct.Pin = Fan_PWMA8_Pin; + GPIO_InitStruct.Pin = Fan_PWMA8_Pin|Fan_PWMA10_Pin; 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(Fan_PWMA8_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USER CODE BEGIN TIM1_MspPostInit 1 */ @@ -555,13 +543,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM1_CLK_DISABLE(); - - /**TIM1 GPIO Configuration - PA8 ------> TIM1_CH1 - PA10 ------> TIM1_CH3 - */ - HAL_GPIO_DeInit(GPIOA, Fan_PWMA8_Pin|Fan_PWMA10_Pin); - /* USER CODE BEGIN TIM1_MspDeInit 1 */ /* USER CODE END TIM1_MspDeInit 1 */ diff --git a/shepherd2.ioc b/shepherd2.ioc index c04437e..6d47f6e 100644 --- a/shepherd2.ioc +++ b/shepherd2.ioc @@ -310,7 +310,7 @@ ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_CAN1_Init-CAN1-false-HAL-true,4-MX_CAN2_Init-CAN2-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI3_Init-SPI3-false-HAL-true,8-MX_UART4_Init-UART4-false-HAL-true,9-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,10-MX_I2C1_Init-I2C1-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_CAN1_Init-CAN1-false-HAL-true,4-MX_CAN2_Init-CAN2-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI3_Init-SPI3-false-HAL-true,8-MX_UART4_Init-UART4-false-HAL-true,9-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,10-MX_I2C1_Init-I2C1-false-HAL-true,11-MX_TIM1_Init-TIM1-false-HAL-true,12-MX_TIM2_Init-TIM2-false-HAL-true,13-MX_TIM8_Init-TIM8-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=16000000 RCC.APB1Freq_Value=16000000 @@ -337,7 +337,7 @@ RCC.VCOOutputFreq_Value=240000000 RCC.VcooutputI2S=160000000 SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 SH.S_TIM1_CH1.ConfNb=1 -SH.S_TIM1_CH3.0=TIM1_CH3 +SH.S_TIM1_CH3.0=TIM1_CH3,PWM Generation3 CH3 SH.S_TIM1_CH3.ConfNb=1 SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 SH.S_TIM8_CH1.ConfNb=1 @@ -387,7 +387,8 @@ SPI3.NSS=SPI_NSS_SOFT SPI3.TIMode=SPI_TIMODE_DISABLE SPI3.VirtualType=VM_MASTER TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -TIM1.IPParameters=Channel-PWM Generation1 CH1 +TIM1.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM1.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation3 CH3 TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 TIM8.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3