qinyunti 发表于 2022-12-15 13:43

【ST NUCLEO-U575ZI-Q 测评 】GPIOG端口点灯问题

<div class='showpostmsg'> 本帖最后由 qinyunti 于 2022-12-15 13:47 编辑

<p>有网友在问为什么PG2点不亮,这是介绍下,因为PG2使用VDDIO2需要单独配置其VDDIO2电源.</p>

<p>&nbsp;</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>需要先使能VDDIO2,注意在PWR配置前需要先使能PWR时钟。</p>

<p>LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_PWR);</p>

<p>HAL_PWREx_EnableVddIO2();</p>

<p>HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY);</p>

<p>先要PWR的SVMCR,bit29置位使能VDDIO2</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>然后PWR的CR3的bit1,选择VDDIO2的来源</p>

<p> &nbsp;</p>

<p>PWR的SVMSR的bit1回读确认是否选择成功。</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>原理图中VDDIO2来源于SB28-&gt;VDD_MCU-&gt;JP5-&gt;VDD,确认该链路OK。</p>

<p>&nbsp;</p>

<p> &nbsp;</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>其他的就和其他端口一样了,注意使能对应端口的时钟。</p>

<div class="parsedown-markdown">
<p>#include &quot;stm32u575xx.h&quot;</p>

<p>#include &quot;stm32u5xx_ll_gpio.h&quot;</p>

<p>#include &quot;stm32u5xx_ll_bus.h&quot;</p>

<p>&nbsp;</p>

<p>void SysTick_Handler(void)</p>

<p>{</p>

<p>static volatile uint32_t num = 0;</p>

<p>if(num++ &gt;= 1000)</p>

<p>{</p>

<p>LL_GPIO_TogglePin(GPIOB, 1u&lt;&lt;7);</p>

<p>LL_GPIO_TogglePin(GPIOG, 1u&lt;&lt;2);</p>

<p>LL_GPIO_TogglePin(GPIOC, 1u&lt;&lt;7);</p>

<p>num=0;</p>

<p>}</p>

<p>HAL_IncTick();</p>

<p>}</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>void delay(uint32_t t)</p>

<p>{</p>

<p>volatile uint32_t timeout = t;</p>

<p>while(t--);</p>

<p>}</p>

<p>&nbsp;</p>

<p>int main(void)</p>

<p>{</p>

<p>HAL_Init();</p>

<p>LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_PWR);</p>

<p>HAL_PWREx_EnableVddIO2();</p>

<p>HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY);</p>

<p>#if 1</p>

<p>LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_PWR);</p>

<p>HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</p>

<p>&nbsp;</p>

<p>RCC_OscInitTypeDef pRCC_OscInitStruct;</p>

<p>pRCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;</p>

<p>pRCC_OscInitStruct.HSIState = RCC_HSI_ON;</p>

<p>pRCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;</p>

<p>pRCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;</p>

<p>pRCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;</p>

<p>pRCC_OscInitStruct.PLL.PLLM = 1;</p>

<p>pRCC_OscInitStruct.PLL.PLLMBOOST = RCC_PLLMBOOST_DIV1;</p>

<p>pRCC_OscInitStruct.PLL.PLLN = 20;</p>

<p>pRCC_OscInitStruct.PLL.PLLP = 1;</p>

<p>pRCC_OscInitStruct.PLL.PLLQ = 1;</p>

<p>pRCC_OscInitStruct.PLL.PLLR = 2;</p>

<p>pRCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_0;</p>

<p>pRCC_OscInitStruct.PLL.PLLFRACN = 0; &nbsp;/* */</p>

<p>HAL_RCC_OscConfig(&amp;pRCC_OscInitStruct);</p>

<p>&nbsp;</p>

<p>RCC_ClkInitTypeDef pRCC_ClkInitStruct;</p>

<p>pRCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;</p>

<p>pRCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;</p>

<p>pRCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;</p>

<p>pRCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;</p>

<p>pRCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;</p>

<p>pRCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV2;</p>

<p>HAL_RCC_ClockConfig(&amp;pRCC_ClkInitStruct, FLASH_LATENCY_4);</p>

<p>#endif</p>

<p>&nbsp;</p>

<p>LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);</p>

<p>LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG);</p>

<p>LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);</p>

<p>&nbsp;</p>

<p>LL_GPIO_InitTypeDef GPIO_InitStruct;</p>

<p>//LL_GPIO_StructInit(&amp;GPIO_InitStruct);</p>

<p>GPIO_InitStruct.Pin = LL_GPIO_PIN_7;</p>

<p>GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;</p>

<p>GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;</p>

<p>GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;</p>

<p>GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;</p>

<p>GPIO_InitStruct.Alternate = LL_GPIO_AF_0;</p>

<p>LL_GPIO_Init(GPIOB, &amp;GPIO_InitStruct);</p>

<p>&nbsp;</p>

<p>GPIO_InitStruct.Pin = LL_GPIO_PIN_2;</p>

<p>GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;</p>

<p>GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;</p>

<p>GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;</p>

<p>GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;</p>

<p>GPIO_InitStruct.Alternate = LL_GPIO_AF_0;</p>

<p>LL_GPIO_Init(GPIOG, &amp;GPIO_InitStruct);</p>

<p>&nbsp;</p>

<p>GPIO_InitStruct.Pin = LL_GPIO_PIN_7;</p>

<p>GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;</p>

<p>GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;</p>

<p>GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;</p>

<p>GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;</p>

<p>GPIO_InitStruct.Alternate = LL_GPIO_AF_0;</p>

<p>LL_GPIO_Init(GPIOC, &amp;GPIO_InitStruct);</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>while(1)</p>

<p>{</p>

<p>///delay(1000000ul);</p>

<p>///LL_GPIO_TogglePin(GPIOB, 1u&lt;&lt;7);</p>

<p>}</p>

<p>}</p>
</div>

<p>&nbsp;</p>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

okhxyyo 发表于 2023-1-12 09:42

<p>测评汇总:免费申请|ST NUCLEO-U575ZI-Q https://bbs.eeworld.com.cn/thread-1228653-1-1.html</p>
页: [1]
查看完整版本: 【ST NUCLEO-U575ZI-Q 测评 】GPIOG端口点灯问题