Counter in KL26Z128

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Counter in KL26Z128

809件の閲覧回数
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

タグ(3)
0 件の賞賛
返信
1 返信

739件の閲覧回数
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 件の賞賛
返信