2016-09-05 06:15 PM
Hi Everyone.
I'm having trouble starting the external 32khz RTC source as fitted to the Nucleo. Are there any issues with this clock on the Nucleo, has anyone got it to work?
Thanks
Martin
2016-09-05 06:52 PM
Which board models specifically, most of the Nucleo boards I have don't come with the 32 KHz crystal.
The crystals aren't inherently difficult to start and test, but the STM32 design has some specific requirements electrically.2016-09-05 07:18 PM
Hi Clive, its the Nucleo64, its marked as X2, ABS25-32.768KHZ-6-T on the schematic.
2016-09-05 10:06 PM
Hazy crystal ball here. What do you mean by trouble and how do you try to start it? Which STM32 device? Which version of Nucleo board (UM mentions 3 different LSE configurations)? What is the state of SB45?
JW2016-09-05 10:27 PM
thanks
Martin
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{ if(hrtc->Instance==RTC) { __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); __HAL_RCC_RTC_ENABLE(); } }void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInit;RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); }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_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); }PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
| RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | RCC_PERIPHCLK_RTC; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); }HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }2016-09-06 06:06 AM
Hi b.m.002,
To get the LSE working correctly, you would make the following change in the shared code: * Replace ''RCC_OSCILLATORTYPE_LSI'' by ''RCC_OSCILLATORTYPE_LSE'' * Replace ''RCC_LSI_ON'' with ''RCC_LSI_OFF'' * Add this line : RCC_OscInitStruct.LSEState = RCC_LSE_ON; * Replace ''RCC_RTCCLKSOURCE_LSI'' with ''RCC_RTCCLKSOURCE_LSE'' -Hannibal-2016-09-06 06:17 AM
I don't use Cube, but you may want to try the supplied example first
[STM32Cube_FW_F3_V1.6.0]\Projects\STM32F303RE-Nucleo\Examples\RTC\RTC_Calendar JW2016-09-06 07:04 PM