Skip to main content
Francisco SinapseEnergia
Associate III
October 2, 2017
Question

STM32f030 RTC interface

  • October 2, 2017
  • 1 reply
  • 432 views
Posted on October 02, 2017 at 19:32

Hi all,

I'm trying to work with STM32f030 RTC internal to save UTC calendar.

I have included in my FW application the followings functions:

- MX_RTC_Init();

- Enable RTC interface in 'stm32f00x_hal_conf.c'

- Defined RTC_ASYNCH_PREDIV  and RTC_SYNCH_PREDIV parameters.

- To save RTC parameter I use 'HAL_RTC_SetTime(hrtc, sTime, RTC_FORMAT_BIN)' & HAL_RTC_SetDate(hrtc, sDate,    RTC_FORMAT_BIN); functions.

- My generic clocksource function is:

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_ON;

RCC_OscInitStruct.LSIState = RCC_LSI_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;

PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

   

At this moment, RTC works fine (I'm monitoring with LCD display).

Then, I integrated the SPI library functions. From this moment, RTC seems frozen. Internal RTC parameters are the same all time.

Could anyone help me?

Thanks in advance.

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    October 2, 2017
    Posted on October 02, 2017 at 20:41

    >>Then, I integrated the SPI library functions. From this moment, RTC seems frozen. Internal RTC parameters are the same all time.  Could anyone help me?

    Guess you'd want to look at the code you added in rather that the parts that were previously working. Clocks, mode, and replicated functions with different settings.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..