找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

STM32电机驱动问题

查看数: 3059 | 评论数: 8 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-2-26 23:29

正文摘要:

STM32原理图如下图,那位大神知道为什么通过指令GPIO_SetBits(GPIOB , GPIO_Pin_0);不能使PB0置1呢?

回复

ID:279769 发表于 2018-2-27 18:44
notstop 发表于 2018-2-27 09:48
参考stm32的库,很简单。如下:
/**
  * @brief  Configures Output GPIO.

设置程序在下面,但不知道那里不行
void GPIO_Configuration(void)
{
          GPIO_InitTypeDef GPIO_InitStructure;

          /* &Eacute;è&Ouml;&Atilde;PB0,PB1,PB8,PB9&iquest;&Uacute;&Icirc;&ordf;&Iacute;&AElig;&Iacute;ì&Ecirc;&auml;&sup3;&ouml;&pound;&not;×&icirc;&acute;ó·&shy;×&ordf;&AElig;&micro;&Acirc;&Ecirc;&Icirc;&ordf;50MHz*/
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_8|GPIO_Pin_9;
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
          GPIO_Init(GPIOB , &GPIO_InitStructure);   
}
ID:279769 发表于 2018-2-27 18:41
lo_ 发表于 2018-2-27 09:06
你是不是IO的管脚模式没有配对啊

请问怎么配对啊
ID:232585 发表于 2018-2-27 11:45
你的负载太大了吧  单片机引脚驱动能力有限
ID:285904 发表于 2018-2-27 11:23
看初始化  管脚模式配置,
ID:285880 发表于 2018-2-27 11:04
先要配置好IO口模式再用库函数!推荐先学寄存器操作再上手库函数。
ID:285880 发表于 2018-2-27 11:02
首先要配置IO口为输出模式,只有配置对后才能用库函数。推荐先学寄存器,有一定了解再上手库函数。
ID:285858 发表于 2018-2-27 09:48
参考stm32的库,很简单。如下:
/**
  * @brief  Configures Output GPIO.
  * @param  Led: Specifies the Led to be configured.
  *   This parameter can be one of following parameters:
  *     @arg DEBUGLED
  *     @arg LEDSERV
  * @retval None
  */
void OutPortInit(void)
{
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);                        //注意这个AFIO时钟一定要打开,否则JTAG REMAP无效
        GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);                //JTAG关闭,SWD使能
        //INIT DebugLed
        RCC_APB2PeriphClockCmd(DebugLed_GPIO_CLK, ENABLE);
        GPIO_InitStructure.GPIO_Pin = DebugLed_PIN;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(DebugLed_GPIO_PORT, &GPIO_InitStructure);
}
ID:285771 发表于 2018-2-27 09:06
你是不是IO的管脚模式没有配对啊

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表