欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
求大神,步進(jìn)電機(jī)仿真的時候只轉(zhuǎn)到45度就停了
[打印本頁]
作者:
w1134
時間:
2019-11-17 11:43
標(biāo)題:
求大神,步進(jìn)電機(jī)仿真的時候只轉(zhuǎn)到45度就停了
#include "motoSTEP.h"
#include "stm32f10x.h"
#define MOTO_PWM_GRP GPIOA
#define MOTO_PWM_PIN GPIO_Pin_8
#define MOTO_PWM_CLK RCC_APB2Periph_GPIOA
#define MOTO_DIR_GRP GPIOA
#define MOTO_DIR_PIN GPIO_Pin_13
void timer1PWM_Init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
TIM_OCInitTypeDef TIM_OCInitStruct;
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | MOTO_PWM_CLK, ENABLE);
/**MOTO CLK PIN**/
GPIO_InitStruct.GPIO_Pin = MOTO_PWM_PIN;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(MOTO_PWM_GRP, &GPIO_InitStruct);
/**MOTO DIR PIN**/
GPIO_InitStruct.GPIO_Pin = MOTO_DIR_PIN;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(MOTO_DIR_GRP, &GPIO_InitStruct);
TIM_TimeBaseInitStruct.TIM_Period = 10000; /*400Hz(2.5ms) */
TIM_TimeBaseInitStruct.TIM_Prescaler = 4;
TIM_TimeBaseInitStruct.TIM_ClockDivision = 0;
TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseInitStruct);
TIM_OCStructInit(&TIM_OCInitStruct);/*ÕâÒ»²½×îºÃ¼ÓÉÏ*/
TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1;//PWMģʽ1
TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStruct.TIM_Pulse = 5000;//Âö¿íµ÷ÖÆ
TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM1, &TIM_OCInitStruct);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM1, ENABLE);
TIM_CtrlPWMOutputs(TIM1, ENABLE);/*ÕâÒ»¸öº¯ÊýÖ»Õë¶Ôtimer1ºÍtimer8*/
TIM_Cmd(TIM1, ENABLE);
}
void mdir(uint8_t dir)
{
if(dir==1)
motoDIR=1;
else
motoDIR=0;
}
作者:
yzwzfyz
時間:
2019-11-18 11:05
你能知道,程序語句中每一句的含義么?它又出自何處?
不是你寫的當(dāng)然不會知道,我也一樣。
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1