Spider 0 9 февраля Опубликовано 9 февраля · Жалоба Всем привет! Столкнулся со странной и казалось бы простой но всё же проблемой, не могу запустить RTC. Прошивка пока пустая, настроено тактование от внутреннего RC8Mhz, USART5 для вывода околоотладочной информации, FWDG (на максимальное время, что-то около 29 сек) и собственно RTC. Так вот RTC не запускаются. void RtcInit( void ) { if( RtcInitialized == false ) { rcu_periph_clock_enable(RCU_BKPI); rcu_periph_clock_enable(RCU_PMU); pmu_backup_write_enable(); bkp_deinit(); rcu_osci_on(RCU_IRC40K); // Это было и так рынее включено, if (rcu_osci_stab_wait(RCU_IRC40K)) { // но пусть будет для наглядности rcu_rtc_clock_config(RCU_RTCSRC_IRC40K); // rcu_periph_clock_enable(RCU_RTC); rtc_register_sync_wait(); // Вот от сюда далее никуда не идём. rtc_lwoff_wait(); rtc_prescaler_set(40 - 1); rtc_lwoff_wait(); rtc_interrupt_disable(RTC_INT_ALARM); rtc_lwoff_wait(); rtc_interrupt_enable(RTC_INT_OVERFLOW); rtc_lwoff_wait(); NVIC_SetPriority( RTC_IRQn, 1); NVIC_EnableIRQ(RTC_IRQn); } RtcInitialized = true; } } Вроде как всё правильно... Согласно даташиту надо синхронизироваться с RTC, что и пытаемся сделать. /*! \brief wait RTC registers synchronized flag set \param[in] none \param[out] none \retval none */ void rtc_register_sync_wait(void) { /* clear RSYNF flag */ RTC_CTL &= ~RTC_CTL_RSYNF; /* loop until RSYNF flag is set */ while(RESET == (RTC_CTL & RTC_CTL_RSYNF)){ } } Quote 17.3.2. RTC reading The APB interface and RTC core are located in two different power supply domains. In the RTC core, only counter and divider registers are readable registers. And the values in the two registers and the RTC flags are internally updated at each rising edge of the RTC clock, which is resynchronized by the APB1 clock. When the APB interface is immediately enabled from a disable state, the read operation is not recommended because the first internal update of the registers has not finished. That means, when a system reset, power reset, waking up from Standby mode or Deep-sleep mode occurs, the APB interface was in disabled state, but the RTC core has been kept running. In these cases, the correct read operation should first clear the RSYNF bit in the RTC _CTL register and wait for it to be set by hardware. While WFI and WFE have no effects on the RTC APB interface. Ну и собственно RTC_CNT всегда НОЛЬ. Я что-то не так понимаю? Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться