Hi!
I'm trying to read the RTC Time Preacaler Register, but it only returns zeros. I'm setting SR[TOF] and SR[TIF] to zero to avoid this problem, but this have not been effective.
Below, my code:
void RTC_init (void){
SIM_SCGC6 |= (SIM_SCGC6_RTC_MASK);
RTC_SR |= (RTC_SR_TCE_MASK|~RTC_SR_TIF_MASK|~RTC_SR_TOF_MASK);
}
int RTC_counter(void){
return RTC_TPR;
}
Anyone knows where is the error?
Thanks in advance,
Rafael
Hi Rafael
The TOF and TIF bit are read only, see the RTC_SR field descriptions.
This bit is cleared by writing the TSR register when the time counter is disabled.
And make sure the clock source you selected is active.
Best Regards
Robin