找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索

STM32電機(jī)驅(qū)動問題

查看數(shù): 3005 | 評論數(shù): 8 | 收藏 0
關(guān)燈 | 提示:支持鍵盤翻頁<-左 右->
    組圖打開中,請稍候......
發(fā)布時間: 2018-2-26 23:29

正文摘要:

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

回復(fù)

ID:279769 發(fā)表于 2018-2-27 18:44
notstop 發(fā)表于 2018-2-27 09:48
參考stm32的庫,很簡單。如下:
/**
  * @brief  Configures Output GPIO.

設(shè)置程序在下面,但不知道那里不行
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 發(fā)表于 2018-2-27 18:41
lo_ 發(fā)表于 2018-2-27 09:06
你是不是IO的管腳模式?jīng)]有配對啊

請問怎么配對啊
ID:232585 發(fā)表于 2018-2-27 11:45
你的負(fù)載太大了吧  單片機(jī)引腳驅(qū)動能力有限
ID:285904 發(fā)表于 2018-2-27 11:23
看初始化  管腳模式配置,
ID:285880 發(fā)表于 2018-2-27 11:04
先要配置好IO口模式再用庫函數(shù)!推薦先學(xué)寄存器操作再上手庫函數(shù)。
ID:285880 發(fā)表于 2018-2-27 11:02
首先要配置IO口為輸出模式,只有配置對后才能用庫函數(shù)。推薦先學(xué)寄存器,有一定了解再上手庫函數(shù)。
ID:285858 發(fā)表于 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關(guān)閉,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 發(fā)表于 2018-2-27 09:06
你是不是IO的管腳模式?jīng)]有配對啊

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表