It's showed as followed.
Hi Li,
Yes, you're write. This value should be 9. The source code is not correct.
Regards,
Jing
Hi
See whether the subroutine subtracts 1 from the passed values or not.
The pre-scaler value should indeed be 1 less than the divider value that is "required".
This is the corresponding initialisation code as used by the uTasker project on the KEA128:
POWER_UP_ATOMIC(6, RTC); // ensure the KE's RTC is powered
rtc_interrupt_handler[iIRQ] = ((RTC_SETUP *)ptrSettings)->int_handler; // enter the handling interrupt
fnEnterInterrupt(irq_RTC_OVERFLOW_ID, PRIORITY_RTC, (void (*)(void))_rtc_handler); // enter interrupt handler
RTC_MOD = (((1000)/ RTC_CLOCK_PRESCALER_2) - 1); // set the match value for 1s
RTC_SC = (RTC_SC_RTIE | RTC_SC_RTIF | _RTC_CLOCK_SOURCE | _RTC_PRESCALER); // clock the RTC from the defined clock source/pre-scaler and enable interrupt
and the register values after the execution:
and so 9 is the value required.
Note however that the LPOCLK (1kHz) is quite inaccurate so deviations (or error) probably are not very noticeable.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KEA128:
- http://www.utasker.com/kinetis/TRK-KEA128.html
- http://www.utasker.com/kinetis/FRDM-KEAZ128Q80.html
For less questions and faster, cheaper developments: try uTasker for Kinetis