Counter in KL26Z128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Counter in KL26Z128

375 Views
rafaeldalazen
Contributor II

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

Tags (3)
0 Kudos
1 Reply

305 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

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.

RTC_SR.jpg

And make sure the clock source you selected is active.

RTC clock generation.jpg

Best Regards

Robin

0 Kudos