void rtc_show_time(void)
{
uint32_t time_subsecond = 0;
uint8_t subsecond_ss = 0,subsecond_ts = 0,subsecond_hs = 0;
rtc_current_time_get(&rtc_initpara);
/* get the subsecond value of current time, and convert it into fractional format */
time_subsecond = rtc_subsecond_get();
subsecond_ss=(1000-(time_subsecond*1000+1000)/400)/100;
subsecond_ts=(1000-(time_subsecond*1000+1000)/400)%100/10;
subsecond_hs=(1000-(time_subsecond*1000+1000)/400)%10;
printf("Current time: %0.2x:%0.2x:%0.2x .%d%d%d \n\r", \
rtc_initpara.hour, rtc_initpara.minute, rtc_initpara.second,\
subsecond_ss, subsecond_ts, subsecond_hs);
}
程序前期的同步预分频值设为prescaler_s = 0xFF;
这是GD的GD32F4xx_Firmware_Library_V2.1.0里面的例程。
根据手册,亚秒值为 ( FACTOR_S - SSC ) / ( FACTOR_S + 1 ),此程序中为 (255-time_subsecond )/256.
感觉例子上明显不对
|