MKE04Z64 family and accurate periodic timer

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

MKE04Z64 family and accurate periodic timer

ソリューションへジャンプ
2,046件の閲覧回数
ricardcomas
Contributor III

Hello mates, what's up?

We are developing a kind of timer, it counts from 1.200 minutes until 0, I need that component timer of Processor Expert called (TimeInt) was very accurate because of deviation of time, for instance if timer is counting for an hour it loss a second (it's only an example, but really loss some time).

To make counter we use uint16_t variables, and they goes in to event of timer periodic interrupt decreasing.

My base time is 1 ms (timer component was configured with 1 ms tick)

We use a quartz oscillator of 16 Mhz, but we think that CPU isn't take the accurate that quartz offers.

In the CPU component I have got next settings:

foro1.PNG

foro2.PNG

foro3.PNG

foro4.PNG

foro5.PNG

And in the timer component I've got:

tforo1.PNG

tforo2.PNG

Could you help me?¿

Thanks so much!

1 解決策
1,814件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ricard,

  Do you use PIT module?

  Do you try the official KE driver code?

  You said, MCU doesn't start, what the detail question? Do you debug it, where is it stopping?

  You need to give me more details.


Have a great day,
Kerry

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
8 返答(返信)
1,814件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ricard Comas ,

    I still not very clear about your question description: " it counts from 1.200 minutes until 0".

   Please tell me what the timer step you want to realize? 1ms? Do you want to counter download 1.2 minutes with 1ms each steps? If yes, you can use the KE04 timer like PIT, FTM to get the 1ms.

  But please note, if you want to get the very precise timer, I suggest you use the external crystal instead of the internal 37.5KHZ IRC.  So, it means you need to use the FEE mode instead of the FEI mode.

   If you want the 1.2 minute counter down each step with 1ms.

   Take the PIT as an example,  the clock source is the bus clock.

    If you are using the external 16Mhz crystal,  then choose RDIV as 512, the FLL factor is 1280, you will get the 40Mhz core clock, the bus clock can be 20Mhz. You can set the PIT module generate the 1ms timer interrupt.

   Then in the PIT timer interrupt, you can counter download your 1.2minutes, 1.2minutes =1.2*60*1000=72000.

  About the PIT code, I suggest you use the baremetal code instead of PE component.

   The PIT code, you can find it from the KE driver.

FRDM-KEXX Driver Library Package

  But if you want to use the FTM, it is the same thought.

  If you still have question about it, please kindly let me know.

Wish it helps you!


Have a great day,
Kerry

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,814件の閲覧回数
ricardcomas
Contributor III

Hello mate, i just configured just like you say, but MCU doesn't start

0 件の賞賛
返信
1,815件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ricard,

  Do you use PIT module?

  Do you try the official KE driver code?

  You said, MCU doesn't start, what the detail question? Do you debug it, where is it stopping?

  You need to give me more details.


Have a great day,
Kerry

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信
1,814件の閲覧回数
ricardcomas
Contributor III

Hello Kerry.

I'm using a PIT module.

The MCU doesn't start simply, it be frozen.

I have to say that i'm testing it in other PCB that can work with crtystal or not, it is removable, so I configured it witha  external crystal, 16Mhz has you told me, and 1ms of timer PIT,, then when I MCU starts (without crystal) it doesn't work (this is normal, obviously), if I plug the crystal in "runtime" MCu starts work (with timer at 1ms), BUUUT if i unplug crystal again in  "runtime" it follows running!! How is it possible?¿ it hasn't got crystal because itsn't pluged!

0 件の賞賛
返信
1,814件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ricard Comas,

   If you want to test the external crystal, you must make sure the external crystal is really connected stably in your hardware, and you need to make sure your external crystal is oscillating, this is the basic requirement.

   From my own opinion, if you disconnect the crystal, your code function should have problems, because your core even don't have the clock source, if your code is still working, maybe your core clock is not using the external crystal clock.

   Anyway, if you want to use the external crystal, just connect it in your hardware.


Have a great day,
Kerry

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信
1,814件の閲覧回数
ricardcomas
Contributor III

This is my current settings

tt.PNG

tt2.PNG

 Why is 40Mhz core clock? crystal's 16Mhz

0 件の賞賛
返信
1,814件の閲覧回数
ricardcomas
Contributor III

Crystal's working, we has tested it with a osciloscope. We can't understand what does it happens :smileysad:

0 件の賞賛
返信
1,814件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ricard Comas,

    Please check the MKE04 reference manual:

pastedImage_1.png

FLL factor is 1280.

Then you can check your RDIV, it should be 512, (16Mhz/512)*1280=40Mhz, is it right?

Please read the reference manual carefully.

Wish it helps you.

Have a great day,
Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------