@@ -85,42 +85,61 @@ static inline void board_stm32h7_clock_init(void)
85
85
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
86
86
RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSE ;
87
87
88
- /* PLL1 for System Clock */
88
+ // PLL1 for System Clock
89
+ #ifdef TRACE_ETM
90
+ // From H743 eval board manual
91
+ // - ETM can only work at 50 MHz clock by default because ETM signals are shared with other peripherals. If better
92
+ // performance of ETM is required (84 MHz/98 MHz), R217, R230, R231, R234, R236, SB2, SB5, SB8, SB11,
93
+ // SB42, SB57 must be removed to reduce the stub on ETM signals. In this configuration SAI and PDM are not
94
+ // functional and NOR Flash and the address of SRAM are limited on A18.
95
+ // - ETM trace function would be abnormal as SAI_SDB share the same pins with TRACE_D0, and TRACE_D0
96
+ // would be forced high by SAI_SDB. When using ETM trace it is necessary to set ADCDAT1 pin (SAI_SDB signal
97
+ // of the STM32) of audio codec WM8994ECS/R (U22) by software to be tri-state.
98
+
99
+ // Since Trace CLK = PLL1 / 3 --> max PLL1 clock is 150Mhz
100
+ RCC_OscInitStruct .PLL .PLLM = 2 ;
101
+ RCC_OscInitStruct .PLL .PLLN = 24 ;
102
+ RCC_OscInitStruct .PLL .PLLP = 2 ;
103
+ RCC_OscInitStruct .PLL .PLLQ = 4 ;
104
+ RCC_OscInitStruct .PLL .PLLR = 2 ;
105
+ RCC_OscInitStruct .PLL .PLLFRACN = 0 ;
106
+ #else
107
+ // Set PLL1 to 400Mhz
89
108
RCC_OscInitStruct .PLL .PLLM = 5 ;
90
109
RCC_OscInitStruct .PLL .PLLN = 160 ;
91
- RCC_OscInitStruct .PLL .PLLFRACN = 0 ;
92
110
RCC_OscInitStruct .PLL .PLLP = 2 ;
93
111
RCC_OscInitStruct .PLL .PLLR = 2 ;
94
112
RCC_OscInitStruct .PLL .PLLQ = 4 ;
95
-
113
+ #endif
96
114
RCC_OscInitStruct .PLL .PLLVCOSEL = RCC_PLL1VCOMEDIUM ;
97
115
RCC_OscInitStruct .PLL .PLLRGE = RCC_PLL1VCIRANGE_2 ;
98
116
HAL_RCC_OscConfig (& RCC_OscInitStruct );
99
117
118
+
119
+ /* Select PLL as system clock source and configure bus clocks dividers */
120
+ RCC_ClkInitStruct .ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 |
121
+ RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_D3PCLK1 ;
122
+
123
+ RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ;
124
+ RCC_ClkInitStruct .SYSCLKDivider = RCC_SYSCLK_DIV1 ;
125
+ RCC_ClkInitStruct .AHBCLKDivider = RCC_HCLK_DIV2 ;
126
+ RCC_ClkInitStruct .APB1CLKDivider = RCC_APB1_DIV2 ;
127
+ RCC_ClkInitStruct .APB2CLKDivider = RCC_APB2_DIV2 ;
128
+ RCC_ClkInitStruct .APB3CLKDivider = RCC_APB3_DIV2 ;
129
+ HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_2 );
130
+
100
131
/* PLL3 for USB Clock */
101
132
PeriphClkInitStruct .PLL3 .PLL3M = 25 ;
102
133
PeriphClkInitStruct .PLL3 .PLL3N = 336 ;
103
134
PeriphClkInitStruct .PLL3 .PLL3FRACN = 0 ;
104
135
PeriphClkInitStruct .PLL3 .PLL3P = 2 ;
105
- PeriphClkInitStruct .PLL3 .PLL3R = 2 ;
106
136
PeriphClkInitStruct .PLL3 .PLL3Q = 7 ;
137
+ PeriphClkInitStruct .PLL3 .PLL3R = 2 ;
107
138
108
139
PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_USB ;
109
140
PeriphClkInitStruct .UsbClockSelection = RCC_USBCLKSOURCE_PLL3 ;
110
141
HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct );
111
142
112
- /* Select PLL as system clock source and configure bus clocks dividers */
113
- RCC_ClkInitStruct .ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
114
- RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 );
115
-
116
- RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ;
117
- RCC_ClkInitStruct .SYSCLKDivider = RCC_SYSCLK_DIV1 ;
118
- RCC_ClkInitStruct .AHBCLKDivider = RCC_HCLK_DIV2 ;
119
- RCC_ClkInitStruct .APB1CLKDivider = RCC_APB1_DIV2 ;
120
- RCC_ClkInitStruct .APB2CLKDivider = RCC_APB2_DIV2 ;
121
- RCC_ClkInitStruct .APB3CLKDivider = RCC_APB3_DIV1 ;
122
- HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_4 );
123
-
124
143
/*activate CSI clock mondatory for I/O Compensation Cell*/
125
144
__HAL_RCC_CSI_ENABLE () ;
126
145
0 commit comments