c盤清理的步驟是什么(如何清理C盤空間)
如何清理C盤空間怎么清理C盤的垃圾文件?每天上網會給電腦帶來很多臨時文件,這些垃圾文件不清理掉時間久了就會影響到電腦的運行速度。那怎
2022/12/08
(資料圖片僅供參考)
使用STM32MIN開發板操作,對電機進行PWM簡單調速,使用通用定時器TIM3上,下圖為MIN板定時器引腳分布圖
mian.c#include "delay.h"#include "usart.h"#include "motor.h" int main(void) { delay_init(); //延遲函數初始化 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中斷優先級分組設置 uart_init(115200); //串口初始化設置 TIM3_PWM_Init(450,7199); //PWM輸出初始化 while(1) { //設置通道2的占空比實現PWM調速,這里是100,在0~450間,越小速度越快 TIM_SetCompare2(TIM3,300); P5_HIGH; P4_LOW; } }
motor.c#include "motor.h"#include "usart.h" //TIM3 PWM部分初始化//PWM輸出初始化//arr:自動重裝載值//psc 時鐘預分頻系數void TIM3_PWM_Init(u16 arr,u16 psc){ GPIO_InitTypeDef GPIO_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //使能定時器3時鐘 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //使能GPIO外設時鐘 //初始化IOPA4 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_ResetBits(GPIOA,GPIO_Pin_4); //初始化IOPA5 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_ResetBits(GPIOA,GPIO_Pin_5); //初始化IOPA7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //復用推挽輸出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA,&GPIO_InitStructure); //初始化TIM3, TIM_TimeBaseStructure.TIM_Period = arr; //自動重裝載值 TIM_TimeBaseStructure.TIM_Prescaler =psc; //預分頻系數 TIM_TimeBaseStructure.TIM_ClockDivision = 0; //設置時鐘分割 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上計數模式 TIM_TimeBaseInit(TIM3,&TIM_TimeBaseStructure); //初始化TIM3 Channel2 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; //選擇PWM模式2 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //比較輸出使能 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low ; //輸出比較極性地 TIM_OC2Init(TIM3, &TIM_OCInitStructure); TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable); //使能定時器3通道2預裝載寄存器 TIM_Cmd(TIM3, ENABLE); //使能TIM3}
motor.h#ifndef __TIMER_H#define __TIMER_H#include "sys.h"#define P4 GPIO_Pin_4#define P5 GPIO_Pin_5//#define MORTOR_PROT GPIOA#define P4_LOW GPIO_ResetBits(GPIOA,P4)#define P4_HIGH GPIO_SetBits(GPIOA,P4)#define P5_LOW GPIO_ResetBits(GPIOA,P5)#define P5_HIGH GPIO_SetBits(GPIOA,P5) void TIM3_PWM_Init(u16 arr,u16 psc);#endif