改正了角度转到CCR的值,加入了tim7定时中断

This commit is contained in:
james 2024-11-07 13:49:33 +08:00
parent c895308110
commit 2830892d58
22 changed files with 4500 additions and 4247 deletions

View File

@ -1,4 +1,6 @@
#include "main.h" #include "main.h"
//Tanslate angle into Capture Compare Register value
#define ANGLETOCCR(angle) 2000 * (angle) / 180 + 500
extern uint8_t Servo_Speed,Servo_goal,Servo_position; extern uint8_t Servo_Speed,Servo_goal,Servo_position;

View File

@ -57,6 +57,7 @@ void PendSV_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void EXTI9_5_IRQHandler(void); void EXTI9_5_IRQHandler(void);
void USART1_IRQHandler(void); void USART1_IRQHandler(void);
void TIM7_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
/* USER CODE END EFP */ /* USER CODE END EFP */

View File

@ -34,6 +34,8 @@ extern "C" {
extern TIM_HandleTypeDef htim1; extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim7;
extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim15;
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
@ -41,6 +43,7 @@ extern TIM_HandleTypeDef htim15;
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_TIM1_Init(void); void MX_TIM1_Init(void);
void MX_TIM7_Init(void);
void MX_TIM15_Init(void); void MX_TIM15_Init(void);
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);

Binary file not shown.

View File

@ -27,10 +27,14 @@ Project File Date: 11/07/2024
<h2>Output:</h2> <h2>Output:</h2>
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\Keil5\ARM\ARMCC\Bin' *** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\Keil5\ARM\ARMCC\Bin'
Build target 'Project' Build target 'Project'
compiling main.c...
../Src/main.c(126): warning: #177-D: variable "ADC_Value" was declared but never referenced
uint32_t ADC_Value;
../Src/main.c: 1 warning, 0 errors
linking... linking...
Program Size: Code=17940 RO-data=59236 RW-data=36 ZI-data=2820 Program Size: Code=18628 RO-data=59236 RW-data=36 ZI-data=2892
FromELF: creating hex file... FromELF: creating hex file...
"Project\Project.axf" - 0 Error(s), 0 Warning(s). "Project\Project.axf" - 0 Error(s), 1 Warning(s).
<h2>Software Packages used:</h2> <h2>Software Packages used:</h2>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
Dependencies for Project 'Project', Target 'Project': (DO NOT MODIFY !) Dependencies for Project 'Project', Target 'Project': (DO NOT MODIFY !)
F (startup_stm32l475xx.s)(0x672B9D47)(--cpu Cortex-M4.fp -g --apcs=interwork --pd "__MICROLIB SETA 1" -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include --pd "__UVISION_VERSION SETA 514" --pd "_RTE_ SETA 1" --pd "STM32L475xx SETA 1" --list startup_stm32l475xx.lst --xref -o project\startup_stm32l475xx.o --depend project\startup_stm32l475xx.d) F (startup_stm32l475xx.s)(0x672C524E)(--cpu Cortex-M4.fp -g --apcs=interwork --pd "__MICROLIB SETA 1" -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include --pd "__UVISION_VERSION SETA 514" --pd "_RTE_ SETA 1" --pd "STM32L475xx SETA 1" --list startup_stm32l475xx.lst --xref -o project\startup_stm32l475xx.o --depend project\startup_stm32l475xx.d)
F (..\Src\lcd.c)(0x672794C0)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\lcd.o --omf_browse project\lcd.crf --depend project\lcd.d) F (..\Src\lcd.c)(0x672794C0)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\lcd.o --omf_browse project\lcd.crf --depend project\lcd.d)
I (../Inc/sys.h)(0x67279973) I (../Inc/sys.h)(0x67279973)
I (../Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h)(0x671507AF) I (../Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h)(0x671507AF)
@ -116,7 +116,7 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
F (../Src/main.c)(0x672B9D9A)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\main.o --omf_browse project\main.crf --depend project\main.d) F (../Src/main.c)(0x672C5484)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\main.o --omf_browse project\main.crf --depend project\main.d)
I (../Inc/main.h)(0x672B2071) I (../Inc/main.h)(0x672B2071)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF)
I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD) I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD)
@ -155,14 +155,14 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
I (../Inc/adc.h)(0x67284CF2) I (../Inc/adc.h)(0x67284CF2)
I (../Inc/spi.h)(0x67279574) I (../Inc/spi.h)(0x67279574)
I (../Inc/tim.h)(0x672B9D44) I (../Inc/tim.h)(0x672C524A)
I (../Inc/usart.h)(0x67276B93) I (../Inc/usart.h)(0x67276B93)
I (../Inc/gpio.h)(0x6715E327) I (../Inc/gpio.h)(0x6715E327)
I (../Inc/lcd.h)(0x5BF21D0E) I (../Inc/lcd.h)(0x5BF21D0E)
I (../Inc/sys.h)(0x67279973) I (../Inc/sys.h)(0x67279973)
I (D:\Keil5\ARM\ARMCC\include\stdio.h)(0x588B8344) I (D:\Keil5\ARM\ARMCC\include\stdio.h)(0x588B8344)
I (D:\Keil5\ARM\ARMCC\include\string.h)(0x588B8344) I (D:\Keil5\ARM\ARMCC\include\string.h)(0x588B8344)
I (../Inc/servo.h)(0x672B3D09) I (../Inc/servo.h)(0x672C51E6)
F (../Src/gpio.c)(0x672A38B6)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\gpio.o --omf_browse project\gpio.crf --depend project\gpio.d) F (../Src/gpio.c)(0x672A38B6)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\gpio.o --omf_browse project\gpio.crf --depend project\gpio.d)
I (../Inc/gpio.h)(0x6715E327) I (../Inc/gpio.h)(0x6715E327)
I (../Inc/main.h)(0x672B2071) I (../Inc/main.h)(0x672B2071)
@ -277,8 +277,8 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
F (../Src/tim.c)(0x672B9D44)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\tim.o --omf_browse project\tim.crf --depend project\tim.d) F (../Src/tim.c)(0x672C524A)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\tim.o --omf_browse project\tim.crf --depend project\tim.d)
I (../Inc/tim.h)(0x672B9D44) I (../Inc/tim.h)(0x672C524A)
I (../Inc/main.h)(0x672B2071) I (../Inc/main.h)(0x672B2071)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF)
I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD) I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD)
@ -353,7 +353,7 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
F (../Src/stm32l4xx_it.c)(0x672B9D45)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\stm32l4xx_it.o --omf_browse project\stm32l4xx_it.crf --depend project\stm32l4xx_it.d) F (../Src/stm32l4xx_it.c)(0x672C524A)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\stm32l4xx_it.o --omf_browse project\stm32l4xx_it.crf --depend project\stm32l4xx_it.d)
I (../Inc/main.h)(0x672B2071) I (../Inc/main.h)(0x672B2071)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF)
I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD) I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD)
@ -390,9 +390,9 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
I (../Inc/stm32l4xx_it.h)(0x672B9D45) I (../Inc/stm32l4xx_it.h)(0x672C524A)
I (../Inc/tim.h)(0x672B9D44) I (../Inc/tim.h)(0x672C524A)
I (../Inc/servo.h)(0x672B3D09) I (../Inc/servo.h)(0x672C51E6)
I (../Inc/usart.h)(0x67276B93) I (../Inc/usart.h)(0x67276B93)
I (D:\Keil5\ARM\ARMCC\include\stdio.h)(0x588B8344) I (D:\Keil5\ARM\ARMCC\include\stdio.h)(0x588B8344)
I (../Inc/gpio.h)(0x6715E327) I (../Inc/gpio.h)(0x6715E327)
@ -433,8 +433,8 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
F (..\Src\servo.c)(0x672B9D72)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\servo.o --omf_browse project\servo.crf --depend project\servo.d) F (..\Src\servo.c)(0x672C52EE)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\servo.o --omf_browse project\servo.crf --depend project\servo.d)
I (../Inc/servo.h)(0x672B3D09) I (../Inc/servo.h)(0x672C51E6)
I (../Inc/main.h)(0x672B2071) I (../Inc/main.h)(0x672B2071)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF)
I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD) I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD)
@ -471,10 +471,10 @@ I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h)(0x671507AF)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h)(0x671507AF)
I (../Inc/tim.h)(0x672B9D44) I (../Inc/tim.h)(0x672C524A)
I (../Inc/lcd.h)(0x5BF21D0E) I (../Inc/lcd.h)(0x5BF21D0E)
I (../Inc/sys.h)(0x67279973) I (../Inc/sys.h)(0x67279973)
F (..\Inc\servo.h)(0x672B3D09)() F (..\Inc\servo.h)(0x672C51E6)()
F (../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c)(0x671507AF)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\stm32l4xx_hal_adc.o --omf_browse project\stm32l4xx_hal_adc.crf --depend project\stm32l4xx_hal_adc.d) F (../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c)(0x671507AF)(--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I D:\Develop\Stm32Project\Project\MDK-ARM\RTE -I D:\Keil5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\Include -I D:\Keil5\ARM\PACK\Keil\STM32L4xx_DFP\1.4.0\Device\Include -D__UVISION_VERSION="514" -D_RTE_ -DSTM32L475xx -DUSE_HAL_DRIVER -DSTM32L475xx -o project\stm32l4xx_hal_adc.o --omf_browse project\stm32l4xx_hal_adc.crf --depend project\stm32l4xx_hal_adc.d)
I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF) I (../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h)(0x671507AF)
I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD) I (../Inc/stm32l4xx_hal_conf.h)(0x67299DDD)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,9 +23,10 @@ Mcu.IP2=RCC
Mcu.IP3=SPI3 Mcu.IP3=SPI3
Mcu.IP4=SYS Mcu.IP4=SYS
Mcu.IP5=TIM1 Mcu.IP5=TIM1
Mcu.IP6=TIM15 Mcu.IP6=TIM7
Mcu.IP7=USART1 Mcu.IP7=TIM15
Mcu.IPNb=8 Mcu.IP8=USART1
Mcu.IPNb=9
Mcu.Name=STM32L475V(C-E-G)Tx Mcu.Name=STM32L475V(C-E-G)Tx
Mcu.Package=LQFP100 Mcu.Package=LQFP100
Mcu.Pin0=PH0-OSC_IN (PH0) Mcu.Pin0=PH0-OSC_IN (PH0)
@ -36,7 +37,8 @@ Mcu.Pin12=PC12
Mcu.Pin13=PB8 Mcu.Pin13=PB8
Mcu.Pin14=PB9 Mcu.Pin14=PB9
Mcu.Pin15=VP_SYS_VS_Systick Mcu.Pin15=VP_SYS_VS_Systick
Mcu.Pin16=VP_TIM15_VS_ClockSourceINT Mcu.Pin16=VP_TIM7_VS_ClockSourceINT
Mcu.Pin17=VP_TIM15_VS_ClockSourceINT
Mcu.Pin2=PC2 Mcu.Pin2=PC2
Mcu.Pin3=PB2 Mcu.Pin3=PB2
Mcu.Pin4=PE7 Mcu.Pin4=PE7
@ -45,7 +47,7 @@ Mcu.Pin6=PE9
Mcu.Pin7=PB15 Mcu.Pin7=PB15
Mcu.Pin8=PA9 Mcu.Pin8=PA9
Mcu.Pin9=PA10 Mcu.Pin9=PA10
Mcu.PinsNb=17 Mcu.PinsNb=18
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32L475VETx Mcu.UserName=STM32L475VETx
@ -62,6 +64,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA10.Mode=Asynchronous PA10.Mode=Asynchronous
@ -143,7 +146,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath= ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_SPI3_Init-SPI3-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM15_Init-TIM15-false-HAL-true,8-MX_TIM7_Init-TIM7-false-HAL-true ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_SPI3_Init-SPI3-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM15_Init-TIM15-false-HAL-true
RCC.ADCFreq_Value=12000000 RCC.ADCFreq_Value=12000000
RCC.AHBFreq_Value=72000000 RCC.AHBFreq_Value=72000000
RCC.APB1Freq_Value=72000000 RCC.APB1Freq_Value=72000000
@ -231,4 +234,6 @@ VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM15_VS_ClockSourceINT.Mode=Internal VP_TIM15_VS_ClockSourceINT.Mode=Internal
VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT
board=custom board=custom

View File

@ -149,6 +149,7 @@ int main(void)
MX_SPI3_Init(); MX_SPI3_Init();
MX_TIM1_Init(); MX_TIM1_Init();
MX_TIM15_Init(); MX_TIM15_Init();
MX_TIM7_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
LCD_Init(); LCD_Init();
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED); HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
@ -166,7 +167,7 @@ int main(void)
HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_SET);
printf("Hello!"); printf("Hello!");
//__HAL_TIM_SET_COMPARE(&htim15,TIM_CHANNEL_2,5); //__HAL_TIM_SET_COMPARE(&htim15,TIM_CHANNEL_2,5);
//HAL_TIM_Base_Start_IT(&htim7); HAL_TIM_Base_Start_IT(&htim7);
while (1) while (1)
{ //??ADC?? { //??ADC??
// HAL_ADC_PollForConversion(&hadc1, 50); //??????,50???????,???ms // HAL_ADC_PollForConversion(&hadc1, 50); //??????,50???????,???ms
@ -208,8 +209,8 @@ int main(void)
//cnt=(cnt+30)%(180+30); //cnt=(cnt+30)%(180+30);
LCD_ShowxNum(50, 200, cnt, 4, 16, 0); LCD_ShowxNum(50, 200, cnt, 4, 16, 0);
LCD_ShowxNum(50, 150, 2000*cnt/180+500, 4, 16, 0); LCD_ShowxNum(50, 150, ANGLETOCCR(cnt), 4, 16, 0);
Servo_SetAngle(cnt); // Servo_SetAngle(cnt);
HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin); HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
HAL_Delay(1000); HAL_Delay(1000);
if(!LED_B_ON) if(!LED_B_ON)

View File

@ -7,7 +7,7 @@ uint8_t Servo_Speed = 1, Servo_goal = 0, Servo_position = 0;
void Servo_SetAngle(int goal) void Servo_SetAngle(int goal)
{ {
Servo_position = goal; Servo_position = goal;
__HAL_TIM_SET_COMPARE(&htim15, TIM_CHANNEL_2, 2500 * goal / 180 - 500); __HAL_TIM_SET_COMPARE(&htim15, TIM_CHANNEL_2, ANGLETOCCR(goal));
} }
// 往哪个方向转 // 往哪个方向转
@ -16,36 +16,36 @@ int Servo_toward(void)
return Servo_goal > Servo_position; return Servo_goal > Servo_position;
} }
// void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
// { {
// static uint8_t times = 0,tt=0; static uint8_t times = 0,tt=0;
// if (htim == &htim7) if (htim == &htim7)
// { {
// // if (++times == 250) // if (++times == 250)
// // { // {
// // LCD_ShowxNum(50, 50, ++tt, 4, 16, 0); // LCD_ShowxNum(50, 50, ++tt, 4, 16, 0);
// // times = 0; // times = 0;
// // } // }
// // else // else
// // { // {
// // return; // return;
// // } // }
// if (Servo_position == Servo_goal) if (Servo_position == Servo_goal)
// { {
// return; return;
// } }
// if (Servo_Speed == 1) if (Servo_Speed == 1)
// { {
// Servo_position = Servo_goal; Servo_position = Servo_goal;
// } }
// if (Servo_Speed == 2) if (Servo_Speed == 2)
// { {
// Servo_position += Servo_toward() * 9; Servo_position += Servo_toward() * 9;
// } }
// if (Servo_Speed == 3) if (Servo_Speed == 3)
// { {
// Servo_position += Servo_toward(); Servo_position += Servo_toward();
// } }
// Servo_SetAngle(Servo_position); Servo_SetAngle(Servo_position);
// } }
// } }

View File

@ -60,6 +60,7 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern TIM_HandleTypeDef htim7;
extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart1;
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
extern uint8_t Servo_Speed; extern uint8_t Servo_Speed;
@ -234,6 +235,20 @@ void USART1_IRQHandler(void)
/* USER CODE END USART1_IRQn 1 */ /* USER CODE END USART1_IRQn 1 */
} }
/**
* @brief This function handles TIM7 global interrupt.
*/
void TIM7_IRQHandler(void)
{
/* USER CODE BEGIN TIM7_IRQn 0 */
/* USER CODE END TIM7_IRQn 0 */
HAL_TIM_IRQHandler(&htim7);
/* USER CODE BEGIN TIM7_IRQn 1 */
/* USER CODE END TIM7_IRQn 1 */
}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
uint8_t NewCCRValue(int now_ccr,int plus) uint8_t NewCCRValue(int now_ccr,int plus)
{ {

View File

@ -25,6 +25,7 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
TIM_HandleTypeDef htim1; TIM_HandleTypeDef htim1;
TIM_HandleTypeDef htim7;
TIM_HandleTypeDef htim15; TIM_HandleTypeDef htim15;
/* TIM1 init function */ /* TIM1 init function */
@ -91,6 +92,39 @@ void MX_TIM1_Init(void)
/* USER CODE END TIM1_Init 2 */ /* USER CODE END TIM1_Init 2 */
HAL_TIM_MspPostInit(&htim1); HAL_TIM_MspPostInit(&htim1);
}
/* TIM7 init function */
void MX_TIM7_Init(void)
{
/* USER CODE BEGIN TIM7_Init 0 */
/* USER CODE END TIM7_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM7_Init 1 */
/* USER CODE END TIM7_Init 1 */
htim7.Instance = TIM7;
htim7.Init.Prescaler = 0;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 65535;
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM7_Init 2 */
/* USER CODE END TIM7_Init 2 */
} }
/* TIM15 init function */ /* TIM15 init function */
void MX_TIM15_Init(void) void MX_TIM15_Init(void)
@ -182,7 +216,22 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
{ {
if(tim_baseHandle->Instance==TIM15) if(tim_baseHandle->Instance==TIM7)
{
/* USER CODE BEGIN TIM7_MspInit 0 */
/* USER CODE END TIM7_MspInit 0 */
/* TIM7 clock enable */
__HAL_RCC_TIM7_CLK_ENABLE();
/* TIM7 interrupt Init */
HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspInit 1 */
/* USER CODE END TIM7_MspInit 1 */
}
else if(tim_baseHandle->Instance==TIM15)
{ {
/* USER CODE BEGIN TIM15_MspInit 0 */ /* USER CODE BEGIN TIM15_MspInit 0 */
@ -261,7 +310,21 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* tim_pwmHandle)
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
{ {
if(tim_baseHandle->Instance==TIM15) if(tim_baseHandle->Instance==TIM7)
{
/* USER CODE BEGIN TIM7_MspDeInit 0 */
/* USER CODE END TIM7_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM7_CLK_DISABLE();
/* TIM7 interrupt Deinit */
HAL_NVIC_DisableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspDeInit 1 */
/* USER CODE END TIM7_MspDeInit 1 */
}
else if(tim_baseHandle->Instance==TIM15)
{ {
/* USER CODE BEGIN TIM15_MspDeInit 0 */ /* USER CODE BEGIN TIM15_MspDeInit 0 */