We are currently using LPC845 for an application which has a PWM dutycycle input. The frequency of the PWM signal is 2.5 kHz and what is the best method to read this?
Hi, Shankar,
Regarding your question, I think you can use the capture function to measure the PWM signal frequency. Both the CTimer and SCTimer/PWM support the capture features.
For example, you use CTimer0 module to test the PWM signal, you have to have a standard tick signal, which is accurate enough and known frequency signal. You can connect the PWM signal to for example T0_CAP0, connect the high frequency tick signal for example 2.5MHz to T0_CAP1, pls note all the T0_CAP0/T0_CAP1 are pin movable via SWM and selected by PINASSIGN14 register as following fig.
You can select the tick by the CTMOD bits and CINSEL bits in CTimer0 Count Control Register as following, for the case, you can set CTMODE=0x01, CINSEL=0x01, then the signal connected to T0_CAP1 pin will be the tick signal.
You can set the CAP0RE/CAP0FE/CAP0I bits to enable the capture function.
In the capture ISR, you can read the CTimer0 capture register0 to know the current Timer value, you can figure out the difference for two consecutive capture register reading to get the cycle time.
Hope it can help you
BR
XiangJun Rong