Skip to content

Commit 7dc6829

Browse files
committed
enable etm trace support for h743 eval
1 parent 13bb132 commit 7dc6829

File tree

5 files changed

+1440
-16
lines changed

5 files changed

+1440
-16
lines changed

hw/bsp/family_support.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ function(family_configure_common TARGET)
166166
endif ()
167167
endif ()
168168

169+
# ETM Trace
170+
if (TRACE_ETM STREQUAL "1")
171+
target_compile_definitions(${TARGET} PUBLIC TRACE_ETM)
172+
endif ()
173+
169174
endfunction()
170175

171176

hw/bsp/stm32h7/boards/stm32h743eval/board.h

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,42 +85,61 @@ static inline void board_stm32h7_clock_init(void)
8585
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
8686
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
8787

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
89108
RCC_OscInitStruct.PLL.PLLM = 5;
90109
RCC_OscInitStruct.PLL.PLLN = 160;
91-
RCC_OscInitStruct.PLL.PLLFRACN = 0;
92110
RCC_OscInitStruct.PLL.PLLP = 2;
93111
RCC_OscInitStruct.PLL.PLLR = 2;
94112
RCC_OscInitStruct.PLL.PLLQ = 4;
95-
113+
#endif
96114
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
97115
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
98116
HAL_RCC_OscConfig(&RCC_OscInitStruct);
99117

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+
100131
/* PLL3 for USB Clock */
101132
PeriphClkInitStruct.PLL3.PLL3M = 25;
102133
PeriphClkInitStruct.PLL3.PLL3N = 336;
103134
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
104135
PeriphClkInitStruct.PLL3.PLL3P = 2;
105-
PeriphClkInitStruct.PLL3.PLL3R = 2;
106136
PeriphClkInitStruct.PLL3.PLL3Q = 7;
137+
PeriphClkInitStruct.PLL3.PLL3R = 2;
107138

108139
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
109140
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
110141
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
111142

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-
124143
/*activate CSI clock mondatory for I/O Compensation Cell*/
125144
__HAL_RCC_CSI_ENABLE() ;
126145

0 commit comments

Comments
 (0)