AnsweredAssumed Answered

Error in LPTMR SDK

Question asked by Samuel Vestlin on Sep 20, 2018
Latest reply on Dec 18, 2019 by Gauthier Östervall

I'm using the SDK for MKW41Z512 and have found a probable error in the SDK related to the LPTMR. In fsl_lptmr.h there is a function for setting the compare register. For some reason (which does not make sense if the timer is free running) you are not allowed to set the compare to 0. The Reference Manual also states that:

When the LPTMR is enabled and the CNR equals the value in the CMR and increments, TCF is set

hence the compare value needs to be -1 to what is wanted. This results in the following code in the SDK:

static inline void LPTMR_SetTimerPeriod(LPTMR_Type *base, uint32_t ticks)
    assert(ticks > 0);
    base->CMR = ticks - 1;

However, if ticks = 1, assert is OK but 0 will be written to the register, which is not allowed (for normal behaviour)!


In the Reference Manual Rev. No. 3, there is a related error in the documentation. In Chapter 35.3.3 one can read:

If the LPTMR is enabled, the CMR must be altered only when TCF is set.

TCF is the Timer Compare Flag and it does not make sense that you can only alter the compare if a compare match has already happened. I believe that it should be TFC, Timer Free-Running Counter, i.e. you can only alter the compare when the LPTMR is running and is free running, which make sense!