STM32WL33KCV TCXO
Dear Experts,
I have an E04-400 module which contains a 48 MHz tcxo controlled through PB1 pin.
If i set the module to use HSI it can work (blinks an LED, radio is off)
If i set the module to use HSE (and set PB1 to 1 directly when main.c starts) the module doesn't even reach the stage where it is able to blink an LED.
I am using cubemx 6.17.0 to generate the code.
Here's part of main.c file
int main(void) {
/* USER CODE BEGIN 1 */
// === CRITICAL: Power TCXO BEFORE any clock configuration ===
__HAL_RCC_GPIOB_CLK_ENABLE();
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET); // TCXO_EN = High
``
// Reliable delay on HSI (before SysTick/HAL_Init)
for (volatile uint32_t i = 0; i < 160000; i++); // ~10-15 ms
/* USER CODE END 1 */
``
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
``
/* USER CODE BEGIN Init */
/* USER CODE END Init */
``
/* Configure the system clock */
SystemClock_Config();
``
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
``
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
``
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_RTC_Init();
MX_MRSUBG_Init();
``
/* USER CODE BEGIN 2 */
//rf_tx_init();
/* USER CODE END 2 */
``
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
HAL_Delay(500);
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
//process_tx();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
``
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
``
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI
| RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
``
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
``
/** Configure the SYSCLKSource and SYSCLKDivider */
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_DIRECT_HSE;
RCC_ClkInitStruct.SYSCLKDivider = RCC_DIRECT_HSE_DIV1;
``
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_WAIT_STATES_1) != HAL_OK) {
Error_Handler();
}
}Edited to apply source code formatting - please see How to insert source code for future reference.
