熱門: 51單片機(jī) | 24小時必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
![]() |
發(fā)布時間: 2018-2-26 23:29
正文摘要:STM32原理圖如下圖,那位大神知道為什么通過指令GPIO_SetBits(GPIOB , GPIO_Pin_0);不能使PB0置1呢? |
notstop 發(fā)表于 2018-2-27 09:48 設(shè)置程序在下面,但不知道那里不行 void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /* ÉèÖÃPB0,PB1,PB8,PB9¿ÚÎªÍÆÍìÊä³ö£¬×î´ó·­×ªÆµÂÊΪ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); } |
lo_ 發(fā)表于 2018-2-27 09:06 請問怎么配對啊 |
你的負(fù)載太大了吧 單片機(jī)引腳驅(qū)動能力有限 |
看初始化 管腳模式配置, |
先要配置好IO口模式再用庫函數(shù)!推薦先學(xué)寄存器操作再上手庫函數(shù)。 |
首先要配置IO口為輸出模式,只有配置對后才能用庫函數(shù)。推薦先學(xué)寄存器,有一定了解再上手庫函數(shù)。 |
參考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); } |
你是不是IO的管腳模式?jīng)]有配對啊![]() ![]() ![]() |
Powered by 單片機(jī)教程網(wǎng)