PIT LDVAL issue using TimerUnit_LDD on Kinetis

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PIT LDVAL issue using TimerUnit_LDD on Kinetis

2,250 次查看
ScottW
Contributor II

I'm using a PIT timer on a Kinetis K10 to drive ADC sampling, using the TimerUnit_LDD PE component.  My sampling rate is slightly off, I think because the LDVAL value is being calculated incorrectly by PE.

The datasheet (K10P81M100SF2RM Rev. 5, 8 May 2011) says on p. 985 the LDVAL register should be calculated this way:
LDVAL trigger = (period / clock period) - 1

Which in my case:
Period: 5ms (I want a 200Hz sampling rate)
Clock Period: .5us (bus running at 2MHz)

So:
LDVAL = (5000 / .5) - 1 = 9999

If I enter 5ms into the Counter Restart / Period field, the generated code for the component has this:
  /* PIT_LDVAL0: TSV=0x2710 */
  PIT_LDVAL0 = (uint32_t)0x2710UL;     /* Set up load register */

The hex 0x2710 is decimal 10000, (off by one from what I was expecting), and this value gives me a slight error in my sampling rate.  My workaround for now is to enter a period of 4999.5us.

I'm using CW 10.1 with what should be the latest PE 10.1 patches; I also tried with CW 10.2 and I see the same behavior.  

The bottom of my generated files has this for versioning:
**     This file was created by Processor Expert 5.2 [04.49]
**     for the Freescale Kinetis series of microcontrollers.

The top of the generated component file has this for versioning:
Project   : ProcessorExpert
Processor : MK10DN512ZVLK10
Component : TimerUnit_LDD
Version   : Component 01.122, Driver 01.05, CPU db: 3.00.001
Compiler  : CodeWarrior ARM C Compiler

Let me know if this is a bug, or working as intended... then I'll know if I need to keep an eye on undoing this workaround if it gets modified.

Thanks!

标签 (1)
标记 (1)
0 项奖励
回复
2 回复数

1,246 次查看
ProcessorExpert
Senior Contributor III

Hello,

 

we will fix the PIT timing calculations according to the RM for next release of PEx.

 

best regards
Vojtech Filip
Processor Expert Support Team

0 项奖励
回复

1,246 次查看
emilien
Contributor III

Hi,

 

It's seems there is the same bug for the k60:

** Project : ProcessorExpert
** Processor : MK60DN512ZVMD10
** Component : TimerUnit_LDD
** Version : Component 01.123, Driver 01.06, CPU db: 3.00.003
** Compiler : IAR ARM C Compiler

 

Which I could fix fast thanks to your post : )

 

Best regards,

 

-- 

Emilien

0 项奖励
回复