![]() |
發布時間: 2018-2-26 23:29
正文摘要:STM32原理圖如下圖,那位大神知道為什么通過指令GPIO_SetBits(GPIOB , GPIO_Pin_0);不能使PB0置1呢? |
notstop 發表于 2018-2-27 09:48 設置程序在下面,但不知道那里不行 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_ 發表于 2018-2-27 09:06 請問怎么配對啊 |
你的負載太大了吧 單片機引腳驅動能力有限 |
看初始化 管腳模式配置, |
先要配置好IO口模式再用庫函數!推薦先學寄存器操作再上手庫函數。 |
首先要配置IO口為輸出模式,只有配置對后才能用庫函數。推薦先學寄存器,有一定了解再上手庫函數。 |
參考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); } |
你是不是IO的管腳模式沒有配對啊![]() ![]() ![]() |