Why does the Kinetis K10 Low-Power Timer only count when I try writing to LPTMR0_CNR?

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

Why does the Kinetis K10 Low-Power Timer only count when I try writing to LPTMR0_CNR?

ソリューションへジャンプ
717件の閲覧回数
ryan1
Contributor II

I have a project that's almost done and we're going to use the LPTMR (low-power timer) as a counter with a pulse input. When I go to read the LPTMR_CNR like so:

lptmrCounta = LPTMR0_CNR;

lptmrCountb = LPTMR0_CNR;

It does not work. All I get is a 0 no matter how many times I create a pulse. However, when I try to write to the CNR first, like so:

LPTMR0_CNR = 0;

lptmrCounta = LPTMR0_CNR;

lptmrCountb = LPTMR0_CNR;

It works every time. The documentation shows that the CNR is read only and it says nothing about writing to it before reading it. So why does it work only when I try to write to it?

ラベル(2)
0 件の賞賛
返信
1 解決策
619件の閲覧回数
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Ryan Phillips

In the LPTMR chapter of the Reference Manual for kinetis K10, in the 4.5 section "LPTMR counter", they explain why you need to do this.

pastedImage_0.png

Hope this answer your question, please tell me if you have other question
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
620件の閲覧回数
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Ryan Phillips

In the LPTMR chapter of the Reference Manual for kinetis K10, in the 4.5 section "LPTMR counter", they explain why you need to do this.

pastedImage_0.png

Hope this answer your question, please tell me if you have other question
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
619件の閲覧回数
ryan1
Contributor II

Can you point me to where you got the new version of the reference manual? The one on the product page (ARM Cortex-M4|Kinetis K10 72 MHz 32-bit MCUs|NXP) is Rev 1.1 from December of 2012 but it says it was modified in June of last year. Rev 1.1 does not include the note about the CNR being written to before reading it. it just says 2 read accesses are recommended:

The CNR cannot be initialized, but can be read at any time. Reading the CNR at the time

it is incrementing may return invalid data due to synchronization of the read data bus. If it

is necessary for software to read the CNR, it is recommended that two read accesses are

performed and software verifies that the same data was returned for both reads.

0 件の賞賛
返信