diff --git a/cube/Core/Inc/main.h b/cube/Core/Inc/main.h index 473f15a..992a6c5 100644 --- a/cube/Core/Inc/main.h +++ b/cube/Core/Inc/main.h @@ -61,6 +61,7 @@ void Error_Handler(void); #define eepromSpi hspi1 #define etherSpi hspi2 #define debugUart huart1 +#define mainsCnt htim1 #define LED_Red_Pin GPIO_PIN_13 #define LED_Red_GPIO_Port GPIOC #define LED_Green_Pin GPIO_PIN_14 diff --git a/cube/Core/Inc/stm32f1xx_it.h b/cube/Core/Inc/stm32f1xx_it.h index a38ae00..cbb37a7 100644 --- a/cube/Core/Inc/stm32f1xx_it.h +++ b/cube/Core/Inc/stm32f1xx_it.h @@ -56,6 +56,7 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); +void TIM1_CC_IRQHandler(void); void SPI1_IRQHandler(void); void USART1_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/cube/Core/Src/stm32f1xx_it.c b/cube/Core/Src/stm32f1xx_it.c index 53154ee..23f5010 100644 --- a/cube/Core/Src/stm32f1xx_it.c +++ b/cube/Core/Src/stm32f1xx_it.c @@ -60,6 +60,7 @@ /* External variables --------------------------------------------------------*/ extern SPI_HandleTypeDef hspi1; +extern TIM_HandleTypeDef htim1; extern UART_HandleTypeDef huart1; /* USER CODE BEGIN EV */ @@ -203,6 +204,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32f1xx.s). */ /******************************************************************************/ +/** + * @brief This function handles TIM1 capture compare interrupt. + */ +void TIM1_CC_IRQHandler(void) +{ + /* USER CODE BEGIN TIM1_CC_IRQn 0 */ + + /* USER CODE END TIM1_CC_IRQn 0 */ + HAL_TIM_IRQHandler(&htim1); + /* USER CODE BEGIN TIM1_CC_IRQn 1 */ + + /* USER CODE END TIM1_CC_IRQn 1 */ +} + /** * @brief This function handles SPI1 global interrupt. */ diff --git a/cube/Core/Src/stm32f1xx_it.c-bak b/cube/Core/Src/stm32f1xx_it.c-bak index 2e4132b..a383998 100644 --- a/cube/Core/Src/stm32f1xx_it.c-bak +++ b/cube/Core/Src/stm32f1xx_it.c-bak @@ -57,6 +57,7 @@ /* External variables --------------------------------------------------------*/ extern SPI_HandleTypeDef hspi1; +extern TIM_HandleTypeDef htim1; extern UART_HandleTypeDef huart1; /* USER CODE BEGIN EV */ @@ -198,6 +199,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32f1xx.s). */ /******************************************************************************/ +/** + * @brief This function handles TIM1 capture compare interrupt. + */ +void TIM1_CC_IRQHandler(void) +{ + /* USER CODE BEGIN TIM1_CC_IRQn 0 */ + + /* USER CODE END TIM1_CC_IRQn 0 */ + HAL_TIM_IRQHandler(&htim1); + /* USER CODE BEGIN TIM1_CC_IRQn 1 */ + + /* USER CODE END TIM1_CC_IRQn 1 */ +} + /** * @brief This function handles SPI1 global interrupt. */ diff --git a/cube/Core/Src/tim.c b/cube/Core/Src/tim.c index 3ed85b7..199fce9 100644 --- a/cube/Core/Src/tim.c +++ b/cube/Core/Src/tim.c @@ -91,6 +91,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /* TIM1 interrupt Init */ + HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(TIM1_CC_IRQn); /* USER CODE BEGIN TIM1_MspInit 1 */ /* USER CODE END TIM1_MspInit 1 */ @@ -113,6 +116,8 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); + /* TIM1 interrupt Deinit */ + HAL_NVIC_DisableIRQ(TIM1_CC_IRQn); /* USER CODE BEGIN TIM1_MspDeInit 1 */ /* USER CODE END TIM1_MspDeInit 1 */ diff --git a/cube/Makefile b/cube/Makefile index fb58f24..9e77137 100644 --- a/cube/Makefile +++ b/cube/Makefile @@ -1,6 +1,6 @@ # Processed by ../tools/insertMyCode.sh ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sun Jan 31 20:49:49 CET 2021] +# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sat Feb 06 15:53:10 CET 2021] ########################################################################################################################## # ------------------------------------------------ diff --git a/cube/Makefile-bak b/cube/Makefile-bak index 46b4055..22fa11b 100644 --- a/cube/Makefile-bak +++ b/cube/Makefile-bak @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sun Jan 31 20:49:49 CET 2021] +# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sat Feb 06 15:53:10 CET 2021] ########################################################################################################################## # ------------------------------------------------ diff --git a/cube/cube.ioc b/cube/cube.ioc index 06e57d7..08ded81 100644 --- a/cube/cube.ioc +++ b/cube/cube.ioc @@ -37,7 +37,7 @@ Mcu.Pin8=PB11 Mcu.Pin9=PB12 Mcu.PinsNb=22 Mcu.ThirdPartyNb=0 -Mcu.UserConstants=eepromSpi,hspi1;etherSpi,hspi2;debugUart,huart1 +Mcu.UserConstants=eepromSpi,hspi1;etherSpi,hspi2;debugUart,huart1;mainsCnt,htim1 Mcu.UserName=STM32F103C8Tx MxCube.Version=6.0.0 MxDb.Version=DB.6.0.0 @@ -52,6 +52,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SPI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true +NVIC.TIM1_CC_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false PA10.GPIOParameters=GPIO_Label