2023-10-12 01:20 AM
Hello,
I have an STM32l476G evaluation board. I've configured the CubeMX project to enable the RTC to be run from the 32KHz LSE crystal which should be X1 on the board. However, when putting an oscilloscope on the x1 pins, I do not see any oscillation coming from the pins. I'm not sure if there's a jumper, or bridge I need to change on the board, as I can't find the schematic for the evaluation board online. PC14 and PC15 does not oscillate as well, which is expected as I can't see anything coming from the crystal.
2023-10-12 02:28 AM - edited 2023-10-12 02:31 AM
Hello @JSC4 and welcome to the Community :),
You can find the Schematic board in the CAD Resources of STM32L476G-EVAL.
I advise to check the solder bridge, for that I recommend you the UM1855.
I hope this help you!
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-12 04:05 AM
Thanks for pointing me to the CAD files. I still don't understand why it's not working. The solder bridge settings for X1 (SB41/SB33) are exactly like the X2 settings (SB24/SB23). By just powering the board, should both crystals be working, or does it have to do with firmware as well?
2023-10-12 06:06 AM
LSE won't oscillate until you enable it in RCC_BDCR. Read it out and check.
Check VBAT pin, too.
JW
2023-10-12 06:17 AM - edited 2023-10-12 07:38 AM
Hello @JSC4 ,
The HSE or LSE oscillator is switched ON (by setting the HSEON or LSEON bit in the RCC_CR or RCC_BDCR in registers) the oscillator takes control of its associated pins and the GPIO configuration of these pins has no effect.
In this case and when the oscillator is configured in a user external clock mode, only the pin is reserved for
clock input and the OSC_OUT or OSC32_OUT pin can still be used as normal GPIO.
Note that, the PC13/PC14/PC15 GPIO functionality is lost when the core supply domain is powered off (when the device enters Standby mode). In this case, if their GPIO configuration is not bypassed by the RTC configuration, these pins are set in an analog input mode.
Please refer to the reference manual STM32L47xxx, STM32L48xxx, STM32L49xxx and STM32L4Axxx advanced Arm®-based 32-bit MCUs - Reference manual and precisely Reset and clock control (RCC) Section.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-13 01:35 AM
So in the code generated by cubemx I changed the line:
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
When I checked on the scope, only one pin of the oscillator was oscillating. Initially, it was set to low. Now I'm not sure why that is. As well as I doubt the RTC is being clocked from the external crystal.
The systemclock_config that was generated looks like below:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 24;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
/** Enables the Clock Security System
*/
HAL_RCCEx_EnableLSECSS();
}