Capture_LDD SelectCaptureEdge

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

Capture_LDD SelectCaptureEdge

Jump to solution
1,109 Views
xiaocongfu
NXP Employee
NXP Employee

Hello

I'm using Capture_LDD in processor expert, with the frdm KL25Z.

What I need to do is count the time from the first rising edge of a signal, and then count the time of every falling and rising edge.

I set the Edge in Event as 'rising edge':

event.PNG

and in my code, I use the function :

Cap1_SelectCaptureEdge(Cap1DeviceData,EDGE_BOTH);

to change the property of Edge.

But it seems that 'SelectCaptureEdge' changes nothing because all the values I got are time of the apprance of rising edge.

Does someone have the same problem with this function? Please let me know.

Thanks a lot.

0 Kudos
1 Solution
605 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked the reference manual (KL25 Sub-Family Reference Manual, Rev. 3, September 2012) and there is the following statement about TPMx_CnSC register (used for configuration of the capture edge):

When switching from one channel mode to a different channel mode, the channel must first be disabled and this must be acknowledged in the LPTPM counter clock domain.

Therefor it is not possible to directly call the method:

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_BOTH);

You must use the following way:

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_NONE);

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_BOTH);

The first command set all bits to the zero (dsiable state) and the second command sets the required edge mode. I have created a demo application that process measuring of a signal generated by the second TPM device (TimerOut_LDD component used), see the attachment. You must connect the PTD0 and PTE20 pins, see below:

pastedImage_4.png

When you connect these pins, you can run the application by using debugger. The application is stopped by debugger (__asm( "BKPT 255") instruction) in the Events.c module that is the application code (RisingEdgeAverageVal and BothEdgeAverageVal variables contains the average values for rising edge and both edges measurement of the signal).

The Capture use TPM0 counter that runs on 2.621MHz (clock frequency of the counter). The TimerOut generate signal with 20ms period by using TPM1 device. You can easily compute that the captured values correspond to the period of the signal (rising edge average value is 0xCCb7 * (1 / 2.621 MHz) = 20ms, both edges average value is 0x6650 * (1 / 2.621 MHz) = 10ms).

Best Regards,

Marek Neuzil

View solution in original post

0 Kudos
2 Replies
606 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked the reference manual (KL25 Sub-Family Reference Manual, Rev. 3, September 2012) and there is the following statement about TPMx_CnSC register (used for configuration of the capture edge):

When switching from one channel mode to a different channel mode, the channel must first be disabled and this must be acknowledged in the LPTPM counter clock domain.

Therefor it is not possible to directly call the method:

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_BOTH);

You must use the following way:

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_NONE);

Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_BOTH);

The first command set all bits to the zero (dsiable state) and the second command sets the required edge mode. I have created a demo application that process measuring of a signal generated by the second TPM device (TimerOut_LDD component used), see the attachment. You must connect the PTD0 and PTE20 pins, see below:

pastedImage_4.png

When you connect these pins, you can run the application by using debugger. The application is stopped by debugger (__asm( "BKPT 255") instruction) in the Events.c module that is the application code (RisingEdgeAverageVal and BothEdgeAverageVal variables contains the average values for rising edge and both edges measurement of the signal).

The Capture use TPM0 counter that runs on 2.621MHz (clock frequency of the counter). The TimerOut generate signal with 20ms period by using TPM1 device. You can easily compute that the captured values correspond to the period of the signal (rising edge average value is 0xCCb7 * (1 / 2.621 MHz) = 20ms, both edges average value is 0x6650 * (1 / 2.621 MHz) = 10ms).

Best Regards,

Marek Neuzil

0 Kudos
605 Views
xiaocongfu
NXP Employee
NXP Employee

Hello Marek,

Yes you are right !

I have added Cap1_SelectCaptureEdge(Cap1_DeviceData,EDGE_NONE)  to disable the channel first, and it works well. It has the same result as expected !

Thank you very much !

Xiaocong

0 Kudos