gearhead1107

Using TPM for basic capture

Discussion created by gearhead1107 on Jul 28, 2016

I recently got through an issue using the TPM for period capture on my S32, and figured I would share the resolution in case people need it later:

 

Problem 1: The program won't initialize and gets caught by the watchdog when just trying to use a single channel of the TPM to measure period with FTM_DRV_InitInputCapture();

 

The problem here is that the driver is designed to allow you to either use one channel in a typical input capture mode, or two channels in dual or "period measurement" mode. This would normally be fine except that it still tries to query the second channel for use as an index - if that second channel hasn't been enabled, the program will lock up.

 

Problem 2: The capture isn't a consistent period - edge events happen with frequency but the value isn't consistent.

 

The problem here is that by default the channel will not reset the counter during a capture event. Because of this, the counter will overflow continuously and edge events will pick up whatever number is in the counter at the time. Changing the ICRST bit for that channel to a 1 will reset the counter on that channel each time there's an event.

Outcomes