How to use PWT to capture the pulse width with KE06

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

How to use PWT to capture the pulse width with KE06

837 Views
zhongshen
Contributor III

I have a  FRDM-KE06Z. I hope to use PWT to capture the pulse width. The attached is my KDS project with PE.

 

I use GPIO( as BusTx) to send a pulse series on pin PTD0, connected pin PTD5( as PWT input).

 

PWT is configured  as "The first falling edge starts the pulse width measurement, and on all the subsequent rising and falling edges, the pulse width is captured.",  PWT Clock is set to 24Mhz, enable PWT to generate interrupt when PWTRDY is set and enable PWT to generate interrupt when PWTOV is set.

 

When the program is running, and press sw2 button (sand a frame), I can see the signal on pin PTD5(PWT input pin). But PWT do not take the any data for pulse width. In fact, I can check the PWT overflow interrupt was taken place, and if I let the PTD5 as float, PWT can capture a pulse data to print in random.

 

Could you advise me the solution for it?

 

Many thanks!

 

Best regards,

 

Robert

Original Attachment has been moved to: ke06PWT.zip

Labels (1)
0 Kudos
3 Replies

511 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Zhong,

Normally the user can calculate the frequency of input pulse by reading PPW and NPW.
If the pulse width which you want to measure is larger than 'Max pulse width', that may cause the problem.

Max pulse width.png
You can connect a higher frequency signal to test whether the PWT can measure correct width.
For example:

Enable the Bus clock output on PTH2. (SIM_SOPT0[CLKOE]=1)

And enable bus clock output via an optional prescaler. (SIM_SOPT0[BUSREF]=100)

And then connect PTH2 to PTD5(as PWT input).

Best Regards,

Robin

 

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

0 Kudos

511 Views
zhongshen
Contributor III

Hi Robin,

Thanks for you reply.

I known the PWT to measure fast frequency. In my project, created tx frame on PTD0 in about 27kbps, which can see on the scope and connect to PWT input (PTD5), the problem I met is PWT can take interrupt on overflow, but it cannot capture any pulse width, as like as PWT input does not connect anything.

I guess that maybe PE configuration has bug? Please give me a fevor  to check.

Thanks. 

0 Kudos

511 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Test with the FRDM-KE06Z REV A1 board. Press the SW2 and wait the code stop at the breakpoiont.

Not sure if these results meet your needs.

But the PWT seems works and catched first Positive pulse and second Negative pulse.

imageFile.png

intervel_time[0] catch the NegativeWidth, and it meet the data: 0xfcb/24MHz=168.46us

intervel_time[0].png

intervel_time[1] catch the PositiveWidth, and it meet the data: 0x1da/24MHz=19.75us

intervel_time[1].png

Best Regards,

Robin

 

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

0 Kudos