Modified 'Timebase Source' from TIM1 to TIM17, TIM1 now operates with 1 MHz input and 1 ms period, channel 1 is configured as PWM output mode and mapped to PA8 to drive a buzzer.
This commit is contained in:
@@ -50,7 +50,7 @@ void NMI_Handler(void);
|
|||||||
void HardFault_Handler(void);
|
void HardFault_Handler(void);
|
||||||
void DMA1_Channel1_IRQHandler(void);
|
void DMA1_Channel1_IRQHandler(void);
|
||||||
void DMA1_Channel2_3_IRQHandler(void);
|
void DMA1_Channel2_3_IRQHandler(void);
|
||||||
void TIM1_BRK_UP_TRG_COM_IRQHandler(void);
|
void TIM17_IRQHandler(void);
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the tim.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2026 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __TIM_H__
|
||||||
|
#define __TIM_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_TIM1_Init(void);
|
||||||
|
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TIM_H__ */
|
||||||
|
|
||||||
+4
-4
@@ -68,11 +68,11 @@ void MX_GPIO_Init(void)
|
|||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PA0 PA1 PA4 PA5
|
/*Configure GPIO pins : PA0 PA1 PA4 PA5
|
||||||
PA6 PA7 PA8 PA11
|
PA6 PA7 PA11 PA12
|
||||||
PA12 PA15 */
|
PA15 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
|
||||||
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_11
|
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_11|GPIO_PIN_12
|
||||||
|GPIO_PIN_12|GPIO_PIN_15;
|
|GPIO_PIN_15;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|||||||
+4
-2
@@ -20,6 +20,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "dma.h"
|
#include "dma.h"
|
||||||
|
#include "tim.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
@@ -92,6 +93,7 @@ int main(void)
|
|||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
MX_USART2_UART_Init();
|
MX_USART2_UART_Init();
|
||||||
|
MX_TIM1_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
@@ -166,7 +168,7 @@ void SystemClock_Config(void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Period elapsed callback in non blocking mode
|
* @brief Period elapsed callback in non blocking mode
|
||||||
* @note This function is called when TIM1 interrupt took place, inside
|
* @note This function is called when TIM17 interrupt took place, inside
|
||||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||||
* a global variable "uwTick" used as application time base.
|
* a global variable "uwTick" used as application time base.
|
||||||
* @param htim : TIM handle
|
* @param htim : TIM handle
|
||||||
@@ -177,7 +179,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||||||
/* USER CODE BEGIN Callback 0 */
|
/* USER CODE BEGIN Callback 0 */
|
||||||
|
|
||||||
/* USER CODE END Callback 0 */
|
/* USER CODE END Callback 0 */
|
||||||
if (htim->Instance == TIM1)
|
if (htim->Instance == TIM17)
|
||||||
{
|
{
|
||||||
HAL_IncTick();
|
HAL_IncTick();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,12 @@
|
|||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
TIM_HandleTypeDef htim1;
|
TIM_HandleTypeDef htim17;
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function configures the TIM1 as a time base source.
|
* @brief This function configures the TIM17 as a time base source.
|
||||||
* The time source is configured to have 1ms time base with a dedicated
|
* The time source is configured to have 1ms time base with a dedicated
|
||||||
* Tick interrupt priority.
|
* Tick interrupt priority.
|
||||||
* @note This function is called automatically at the beginning of program after
|
* @note This function is called automatically at the beginning of program after
|
||||||
@@ -47,15 +47,15 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
|||||||
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
|
||||||
/* Enable TIM1 clock */
|
/* Enable TIM17 clock */
|
||||||
__HAL_RCC_TIM1_CLK_ENABLE();
|
__HAL_RCC_TIM17_CLK_ENABLE();
|
||||||
|
|
||||||
/* Get clock configuration */
|
/* Get clock configuration */
|
||||||
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
||||||
|
|
||||||
/* Get APB1 prescaler */
|
/* Get APB1 prescaler */
|
||||||
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
|
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
|
||||||
/* Compute TIM1 clock */
|
/* Compute TIM17 clock */
|
||||||
if (uwAPB1Prescaler == RCC_HCLK_DIV1)
|
if (uwAPB1Prescaler == RCC_HCLK_DIV1)
|
||||||
{
|
{
|
||||||
uwTimclock = HAL_RCC_GetPCLK1Freq();
|
uwTimclock = HAL_RCC_GetPCLK1Freq();
|
||||||
@@ -65,39 +65,39 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
|||||||
uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq();
|
uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
|
/* Compute the prescaler value to have TIM17 counter clock equal to 1MHz */
|
||||||
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
||||||
|
|
||||||
/* Initialize TIM1 */
|
/* Initialize TIM17 */
|
||||||
htim1.Instance = TIM1;
|
htim17.Instance = TIM17;
|
||||||
|
|
||||||
/* Initialize TIMx peripheral as follow:
|
/* Initialize TIMx peripheral as follow:
|
||||||
* Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
|
* Period = [(TIM17CLK/1000) - 1]. to have a (1/1000) s time base.
|
||||||
* Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
* Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
||||||
* ClockDivision = 0
|
* ClockDivision = 0
|
||||||
* Counter direction = Up
|
* Counter direction = Up
|
||||||
*/
|
*/
|
||||||
htim1.Init.Period = (1000000U / 1000U) - 1U;
|
htim17.Init.Period = (1000000U / 1000U) - 1U;
|
||||||
htim1.Init.Prescaler = uwPrescalerValue;
|
htim17.Init.Prescaler = uwPrescalerValue;
|
||||||
htim1.Init.ClockDivision = 0;
|
htim17.Init.ClockDivision = 0;
|
||||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
|
||||||
status = HAL_TIM_Base_Init(&htim1);
|
status = HAL_TIM_Base_Init(&htim17);
|
||||||
if (status == HAL_OK)
|
if (status == HAL_OK)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Start the TIM time Base generation in interrupt mode */
|
/* Start the TIM time Base generation in interrupt mode */
|
||||||
status = HAL_TIM_Base_Start_IT(&htim1);
|
status = HAL_TIM_Base_Start_IT(&htim17);
|
||||||
if (status == HAL_OK)
|
if (status == HAL_OK)
|
||||||
{
|
{
|
||||||
/* Enable the TIM1 global Interrupt */
|
/* Enable the TIM17 global Interrupt */
|
||||||
HAL_NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
|
HAL_NVIC_EnableIRQ(TIM17_IRQn);
|
||||||
/* Configure the SysTick IRQ priority */
|
/* Configure the SysTick IRQ priority */
|
||||||
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
||||||
{
|
{
|
||||||
/* Configure the TIM IRQ priority */
|
/* Configure the TIM IRQ priority */
|
||||||
HAL_NVIC_SetPriority(TIM1_BRK_UP_TRG_COM_IRQn, TickPriority, 0U);
|
HAL_NVIC_SetPriority(TIM17_IRQn, TickPriority, 0U);
|
||||||
uwTickPrio = TickPriority;
|
uwTickPrio = TickPriority;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -113,25 +113,25 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Suspend Tick increment.
|
* @brief Suspend Tick increment.
|
||||||
* @note Disable the tick increment by disabling TIM1 update interrupt.
|
* @note Disable the tick increment by disabling TIM17 update interrupt.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_SuspendTick(void)
|
void HAL_SuspendTick(void)
|
||||||
{
|
{
|
||||||
/* Disable TIM1 update Interrupt */
|
/* Disable TIM17 update Interrupt */
|
||||||
__HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
|
__HAL_TIM_DISABLE_IT(&htim17, TIM_IT_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resume Tick increment.
|
* @brief Resume Tick increment.
|
||||||
* @note Enable the tick increment by Enabling TIM1 update interrupt.
|
* @note Enable the tick increment by Enabling TIM17 update interrupt.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_ResumeTick(void)
|
void HAL_ResumeTick(void)
|
||||||
{
|
{
|
||||||
/* Enable TIM1 Update interrupt */
|
/* Enable TIM17 Update interrupt */
|
||||||
__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
|
__HAL_TIM_ENABLE_IT(&htim17, TIM_IT_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
extern DMA_HandleTypeDef hdma_usart2_rx;
|
extern DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
extern DMA_HandleTypeDef hdma_usart2_tx;
|
extern DMA_HandleTypeDef hdma_usart2_tx;
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
extern TIM_HandleTypeDef htim1;
|
extern TIM_HandleTypeDef htim17;
|
||||||
|
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
|
|
||||||
@@ -133,17 +133,17 @@ void DMA1_Channel2_3_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM1 break, update, trigger and commutation interrupts.
|
* @brief This function handles TIM17 global interrupt.
|
||||||
*/
|
*/
|
||||||
void TIM1_BRK_UP_TRG_COM_IRQHandler(void)
|
void TIM17_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM1_BRK_UP_TRG_COM_IRQn 0 */
|
/* USER CODE BEGIN TIM17_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM1_BRK_UP_TRG_COM_IRQn 0 */
|
/* USER CODE END TIM17_IRQn 0 */
|
||||||
HAL_TIM_IRQHandler(&htim1);
|
HAL_TIM_IRQHandler(&htim17);
|
||||||
/* USER CODE BEGIN TIM1_BRK_UP_TRG_COM_IRQn 1 */
|
/* USER CODE BEGIN TIM17_IRQn 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM1_BRK_UP_TRG_COM_IRQn 1 */
|
/* USER CODE END TIM17_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the TIM instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2026 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
|
/* TIM1 init function */
|
||||||
|
void MX_TIM1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_Init 0 */
|
||||||
|
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
|
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_Init 1 */
|
||||||
|
htim1.Instance = TIM1;
|
||||||
|
htim1.Init.Prescaler = 63;
|
||||||
|
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim1.Init.Period = 999;
|
||||||
|
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim1.Init.RepetitionCounter = 0;
|
||||||
|
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
|
||||||
|
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
|
sConfigOC.Pulse = 0;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||||
|
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||||
|
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||||
|
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||||
|
sBreakDeadTimeConfig.DeadTime = 0;
|
||||||
|
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||||
|
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||||
|
sBreakDeadTimeConfig.BreakFilter = 0;
|
||||||
|
sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT;
|
||||||
|
sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
|
||||||
|
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
|
||||||
|
sBreakDeadTimeConfig.Break2Filter = 0;
|
||||||
|
sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT;
|
||||||
|
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||||
|
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_Init 2 */
|
||||||
|
HAL_TIM_MspPostInit(&htim1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_pwmHandle->Instance==TIM1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspInit 0 */
|
||||||
|
/* TIM1 clock enable */
|
||||||
|
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN TIM1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(timHandle->Instance==TIM1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_MspPostInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspPostInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**TIM1 GPIO Configuration
|
||||||
|
PA8 ------> TIM1_CH1
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF2_TIM1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM1_MspPostInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspPostInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* tim_pwmHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_pwmHandle->Instance==TIM1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM1_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN TIM1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -57,17 +57,22 @@ Mcu.IP1=FREERTOS
|
|||||||
Mcu.IP2=NVIC
|
Mcu.IP2=NVIC
|
||||||
Mcu.IP3=RCC
|
Mcu.IP3=RCC
|
||||||
Mcu.IP4=SYS
|
Mcu.IP4=SYS
|
||||||
Mcu.IP5=USART2
|
Mcu.IP5=TIM1
|
||||||
Mcu.IPNb=6
|
Mcu.IP6=USART2
|
||||||
|
Mcu.IPNb=7
|
||||||
Mcu.Name=STM32G030F6Px
|
Mcu.Name=STM32G030F6Px
|
||||||
Mcu.Package=TSSOP20
|
Mcu.Package=TSSOP20
|
||||||
Mcu.Pin0=PA2
|
Mcu.Pin0=PA2
|
||||||
Mcu.Pin1=PA3
|
Mcu.Pin1=PA3
|
||||||
Mcu.Pin2=PA13
|
Mcu.Pin2=PB0
|
||||||
Mcu.Pin3=PA14-BOOT0
|
Mcu.Pin3=PB1
|
||||||
Mcu.Pin4=VP_FREERTOS_VS_CMSIS_V1
|
Mcu.Pin4=PB2
|
||||||
Mcu.Pin5=VP_SYS_VS_tim1
|
Mcu.Pin5=PA8
|
||||||
Mcu.PinsNb=6
|
Mcu.Pin6=PA13
|
||||||
|
Mcu.Pin7=PA14-BOOT0
|
||||||
|
Mcu.Pin8=VP_FREERTOS_VS_CMSIS_V1
|
||||||
|
Mcu.Pin9=VP_SYS_VS_tim17
|
||||||
|
Mcu.PinsNb=10
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32G030F6Px
|
Mcu.UserName=STM32G030F6Px
|
||||||
@@ -84,9 +89,9 @@ NVIC.SavedPendsvIrqHandlerGenerated=true
|
|||||||
NVIC.SavedSvcallIrqHandlerGenerated=true
|
NVIC.SavedSvcallIrqHandlerGenerated=true
|
||||||
NVIC.SavedSystickIrqHandlerGenerated=true
|
NVIC.SavedSystickIrqHandlerGenerated=true
|
||||||
NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:false\:true\:false\:true\:false
|
||||||
NVIC.TIM1_BRK_UP_TRG_COM_IRQn=true\:3\:0\:false\:false\:true\:false\:false\:true\:true
|
NVIC.TIM17_IRQn=true\:3\:0\:false\:false\:true\:false\:false\:true\:true
|
||||||
NVIC.TimeBase=TIM1_BRK_UP_TRG_COM_IRQn
|
NVIC.TimeBase=TIM17_IRQn
|
||||||
NVIC.TimeBaseIP=TIM1
|
NVIC.TimeBaseIP=TIM17
|
||||||
NVIC.USART2_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true
|
NVIC.USART2_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
PA13.Mode=Serial_Wire
|
PA13.Mode=Serial_Wire
|
||||||
PA13.Signal=SYS_SWDIO
|
PA13.Signal=SYS_SWDIO
|
||||||
@@ -97,7 +102,12 @@ PA2.Mode=Asynchronous
|
|||||||
PA2.Signal=USART2_TX
|
PA2.Signal=USART2_TX
|
||||||
PA3.Mode=Asynchronous
|
PA3.Mode=Asynchronous
|
||||||
PA3.Signal=USART2_RX
|
PA3.Signal=USART2_RX
|
||||||
|
PA8.Locked=true
|
||||||
|
PA8.Signal=S_TIM1_CH1
|
||||||
|
PB0.Locked=true
|
||||||
PB0__PB1__PB2__PA8.StandardMode=true
|
PB0__PB1__PB2__PA8.StandardMode=true
|
||||||
|
PB1.Locked=true
|
||||||
|
PB2.Locked=true
|
||||||
PB3__PB4__PB5__PB6.StandardMode=true
|
PB3__PB4__PB5__PB6.StandardMode=true
|
||||||
PB7__PB8.StandardMode=true
|
PB7__PB8.StandardMode=true
|
||||||
PC14-OSC32_IN\ (PC14)__PB9.StandardMode=true
|
PC14-OSC32_IN\ (PC14)__PB9.StandardMode=true
|
||||||
@@ -172,11 +182,18 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
|||||||
RCC.USART1Freq_Value=64000000
|
RCC.USART1Freq_Value=64000000
|
||||||
RCC.VCOInputFreq_Value=16000000
|
RCC.VCOInputFreq_Value=16000000
|
||||||
RCC.VCOOutputFreq_Value=128000000
|
RCC.VCOOutputFreq_Value=128000000
|
||||||
|
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
|
||||||
|
SH.S_TIM1_CH1.ConfNb=1
|
||||||
|
TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
||||||
|
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||||
|
TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period,AutoReloadPreload
|
||||||
|
TIM1.Period=999
|
||||||
|
TIM1.Prescaler=63
|
||||||
USART2.IPParameters=VirtualMode-Asynchronous
|
USART2.IPParameters=VirtualMode-Asynchronous
|
||||||
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
||||||
VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1
|
VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1
|
||||||
VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1
|
VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1
|
||||||
VP_SYS_VS_tim1.Mode=TIM1
|
VP_SYS_VS_tim17.Mode=TIM17
|
||||||
VP_SYS_VS_tim1.Signal=SYS_VS_tim1
|
VP_SYS_VS_tim17.Signal=SYS_VS_tim17
|
||||||
board=custom
|
board=custom
|
||||||
rtos.0.ip=FREERTOS
|
rtos.0.ip=FREERTOS
|
||||||
|
|||||||
Reference in New Issue
Block a user