资源简介
可以帮助学习STM32 的小伙伴能够学习ISP的有关知识和下载
代码片段和文件信息
#include “User_encoder.h“
void TIM3_Encoder_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA&GPIO_InitStructure);
TIM_TimebaseStructure.TIM_Prescaler = 0;
TIM_TimebaseStructure.TIM_Period = 65535;
TIM_TimebaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimebaseInit(TIM3 &TIM_TimebaseStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3ENABLE); //码盘
// GPIO_PinRemapConfig(GPIO_PartialRemap_TIM4ENABLE); //码盘TIM4 端口部分重映射
TIM_EncoderInterfaceConfig(TIM3 TIM_EncoderMode_TI12
TIM_ICPolarity_Rising TIM_ICPolarity_Rising);
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICFilter = 0;
TIM_ICInit(TIM3 &TIM_ICInitStructure);
TIM_SetCounter(TIM30);
TIM_Cmd(TIM3 ENABLE);
}
void TIM4_Encoder_Init(void) //右轮编码器采集数据 TIM4部分重映射 PB4 PB5
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB&GPIO_InitStructure);
TIM_TimebaseStructure.TIM_Prescaler = 0;
TIM_TimebaseStructure.TIM_Period = 65535;
TIM_TimebaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimebaseInit(TIM4 &TIM_TimebaseStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOB ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4ENABLE); //码盘
// GPIO_PinRemapConfig(GPIO_PartialRemap_TIM4ENABLE); //码盘TIM4 端口部分重映射
TIM_EncoderInterfaceConfig(TIM4 TIM_EncoderMode_TI12
TIM_ICPolarity_Rising TIM_ICPolarity_Rising);
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICFilter = 0;
TIM_ICInit(TIM4 &TIM_ICInitStructure);
TIM_SetCounter(TIM40);
TIM_Cmd(TIM4 ENABLE);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-25 13:56 STM ISP下载器MCUISP\
文件 1708 2017-11-07 18:15 STM ISP下载器MCUISP\mcuisp - 快捷方式.lnk
文件 2491392 2017-11-07 18:15 STM ISP下载器MCUISP\mcuisp.exe
文件 1863 2018-01-16 13:03 STM ISP下载器MCUISP\mcuispConfig.ini
文件 70063 2017-11-29 21:34 STM ISP下载器MCUISP\ProgramLogs.txt
文件 2459 2018-01-25 16:15 User_encoder.c
评论
共有 条评论