STM32F407 configures PLLI2SCLK to achieve a specific 50MHz clock drive 83848

STM32F407 configures PLLI2SCLK to achieve a specific 50MHz clock drive 83848


When using the 83848 Ethernet chip, it is necessary to output a 50MHz clock and supply it to the STM32 Ethernet peripherals EHERNET and 83848 at the same time. However, the system frequency of the general STM32F407 configuration is 168MHz. No matter how the frequency is divided or the advanced timer is used, the 50MHz clock cannot be accurately output. Clock, this article is to use another dedicated PLL of STM32F407 to achieve a specific clock frequency division output.

MCO2 clock output clock tree introduction

clock tree

STM32F407 can implement MCO1 and MCO2 to provide external clock. The clock configuration route is shown in the figure above: external clock -> PLL_M frequency division (generally 1MHz here) -> PLLI2S_N (multiplier can be set to 150) -> MCO2_Devided (set to 1)
clock output port

PLLI2S configuration function

	GPIO_InitTypeDef GPIO_InitStructure;
	
	RCC_PLLI2SConfig(150, 3);	//配置PLLI2SCLK时钟为150/3=50MHz
	RCC_PLLI2SCmd(ENABLE);	  //开启PLLI2SCLK时钟	

If you need other frequency division clocks, you can directly change RCC_PLLI2SConfig(150, 3);the coefficient 150 in the frequency multiplication coefficient, and 3 is the frequency division coefficient

MCO2 output setting


	// 开启定时器相关的GPIO 外设时钟*/
	RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOC,ENABLE);
	
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	
	GPIO_PinAFConfig(GPIOC,GPIO_Pin_9,GPIO_AF_MCO);//复用模式
	
	RCC_MCO2Config(RCC_MCO2Source_PLLI2SCLK, RCC_MCO2Div_1);//1分频	

Initialize the pin multiplexing output mode, configure the MCO2 clock source to be RCC_MCO2Source_PLLI2SCLK, and the frequency division factor is 1 to output a 50MHz clock

Guess you like

Origin blog.csdn.net/weixin_43058521/article/details/121894334