|
发现初始化时在图形界面设置输出为置位(就是高电平),不能成功,必须在后面重新置位才行,使用时需要当心。 详细看下文 static void MX_GPIO_Init(void) { LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB); /**/ LL_GPIO_SetOutputPin(Pow_Con_GPIO_Port, Pow_Con_Pin); /**/ LL_GPIO_SetOutputPin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin); /**/ LL_GPIO_ResetOutputPin(GPIOB, Dis_Led0_Pin|Dis_Led1_Pin|Dis_Led2_Pin|Dis_Led3_Pin); /**/ LL_GPIO_ResetOutputPin(GPIOA, Dis_Led5_Pin|Dis_Led6_Pin|Dis_Led7_Pin); /**/ GPIO_InitStruct.Pin = Pow_Con_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init(Pow_Con_GPIO_Port, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_14|LL_GPIO_PIN_15; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = Dis_Led0_Pin|Dis_Led1_Pin|Dis_Led2_Pin|Dis_Led3_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_MEDIUM; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = SPI2_NSS_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init(SPI2_NSS_GPIO_Port, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = Dis_Led5_Pin|Dis_Led6_Pin|Dis_Led7_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_MEDIUM; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_15; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6 |LL_GPIO_PIN_7|LL_GPIO_PIN_8; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = Pow_Key_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; LL_GPIO_Init(Pow_Key_GPIO_Port, &GPIO_InitStruct); //必须添加下列代码,否则口初始化默认置位不成功 /**/ LL_GPIO_SetOutputPin(Pow_Con_GPIO_Port, Pow_Con_Pin); /**/ LL_GPIO_SetOutputPin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin); } |
![]() ![]() ![]() ![]() |
| 不知道HAL库有没有这个问题。 |
【STM32U3评测】低功耗模式功耗测量
【STM32N6570-DK评测】3.CubeMX关于DCMIPP和CSI的BUG整理及摄像头使用
【STM32U3评测】并不优雅的点亮WS2812
【STM32U3 评测】人体行为识别
【STM32U3评测】移植RTOS
【STM32U3 评测】串口控制步进电机与LabVIEW数据采集
【STM32U3评测】实战项目:无电池温湿度计
【STM32U3评测】不太一样的点灯及编程测试
STM32开发环境迁移实践:从 CubeMX 生成 CMake 工程到 VS Code 编译与调试
【STM32U3 评测】步进电机驱动
微信公众号
手机版