打印

STM32H7的低功耗串口支持HSI时钟,LSE时钟和D3PCLK时钟,最高速可达33Mbps

[复制链接]
187|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
LPUART可以选择HSI时钟,LSE时钟和D3PCLK1时钟:
1、LPUART时钟选择LSE(32768Hz),最高速度是10922bps,最低8bps。
2、LPUART时钟选择HSI(64MHz),最高值是21MHz,最小值15625bps。
3、LPUART时钟选择D3PCLK1(100MHz),最大值33Mbps,最小值24414bps。


/* 使用LSE(32768Hz),最高速度是10922bps,最低8bps */        
#if defined (LPUART_CLOCK_SOURCE_LSE)
        {
                RCC_OscInitTypeDef RCC_OscInitStruct = {0};

                RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
                RCC_OscInitStruct.LSEState = RCC_LSE_ON;
                RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

                if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK)
                {
                        Error_Handler(__FILE__, __LINE__);               
                }
               
                RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
                RCC_PeriphCLKInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE;
                HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
        }        
/* LPUART时钟选择HSI(64MHz),最高值是21MHz,最小值15625bps */        
#elif defined (LPUART_CLOCK_SOURCE_HSI)
        {

                RCC_OscInitTypeDef RCC_OscInitStruct = {0};

                  RCC_OscInitStruct.OscillatorType      = RCC_OSCILLATORTYPE_HSI;
                  RCC_OscInitStruct.HSIState            = RCC_HSI_ON;
                  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
                  RCC_OscInitStruct.PLL.PLLState        = RCC_PLL_NONE;

                if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK)
                {
                        Error_Handler(__FILE__, __LINE__);               
                }
               
                RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
                RCC_PeriphCLKInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
                HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
        }
/* LPUART时钟选择D3PCLK1(100MHz),最大值33Mbps,最小值24414bps */        
#elif defined (LPUART_CLOCK_SOURCE_D3PCLK1)
        
        RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
        RCC_PeriphCLKInitStruct.Lptim1ClockSelection = RCC_LPUART1CLKSOURCE_D3PCLK1;
        HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
#else
        #error Please select the LPTIM Clock source inside the bsp_lpuart_fifo.c file
#endif

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

384

主题

384

帖子

0

粉丝