ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
2 мая
1392381 Топик полностью
Peter_M (12.01.2024 15:34, просмотров: 114) ответил Eddy_Em на А что за МК?
Функция RTC_SynchroShiftConfig() внутри разблокирует. Вот ее код: 
02330 /**

02331 * @brief Configures the Synchronization Shift Control Settings.

02332 * @note When REFCKON is set, firmware must not write to Shift control register

02333 * @param RTC_ShiftAdd1S : Select to add or not 1 second to the time Calendar.

02334 * This parameter can be one of the following values :

02335 * @arg RTC_ShiftAdd1S_Set: Add one second to the clock calendar.

02336 * @arg RTC_ShiftAdd1S_Reset: No effect.

02337 * @param RTC_ShiftSubFS: Select the number of Second Fractions to Substitute.

02338 * This parameter can be one any value from 0 to 0x7FFF.

02339 * @retval An ErrorStatus enumeration value:

02340 * - SUCCESS: RTC Shift registers are configured

02341 * - ERROR: RTC Shift registers are not configured

02342 */

02343 ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)

02344 {

02345 ErrorStatus status = ERROR;

02346 uint32_t shpfcount = 0;

02347

02348 /* Check the parameters */

02349 assert_param(IS_RTC_SHIFT_ADD1S(RTC_ShiftAdd1S));

02350 assert_param(IS_RTC_SHIFT_SUBFS(RTC_ShiftSubFS));

02351

02352 /* Disable the write protection for RTC registers */

02353 RTC->WPR = 0xCA;

02354 RTC->WPR = 0x53;

02355

02356 /* Check if a Shift is pending*/

02357 if ((RTC->ISR & RTC_ISR_SHPF) != RESET)

02358 {

02359 /* Wait until the shift is completed*/

02360 while (((RTC->ISR & RTC_ISR_SHPF) != RESET) && (shpfcount != SHPF_TIMEOUT))

02361 {

02362 shpfcount++;

02363 }

02364 }

02365

02366 /* Check if the Shift pending is completed or if there is no Shift operation at all*/

02367 if ((RTC->ISR & RTC_ISR_SHPF) == RESET)

02368 {

02369 /* check if the reference clock detection is disabled */

02370 if((RTC->CR & RTC_CR_REFCKON) == RESET)

02371 {

02372 /* Configure the Shift settings */

02373 RTC->SHIFTR = (uint32_t)(uint32_t)(RTC_ShiftSubFS) | (uint32_t)(RTC_ShiftAdd1S);

02374

02375 if(RTC_WaitForSynchro() == ERROR)

02376 {

02377 status = ERROR;

02378 }

02379 else

02380 {

02381 status = SUCCESS;

02382 }

02383 }

02384 else

02385 {

02386 status = ERROR;

02387 }

02388 }

02389 else

02390 {

02391 status = ERROR;

02392 }

02393

02394 /* Enable the write protection for RTC registers */

02395 RTC->WPR = 0xFF;

02396

02397 return (ErrorStatus)(status);

02398 }


МК какой-то китайский клон STM32. У меня калибровка через регистр RTC->CALR не работает, поэтому нужно через регистры подсекунд сделать.