PWM capture registers lpc24xx

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by sns22 on Fri Feb 07 06:03:37 MST 2014

I am not able to understand the functionality of some PWM registers to be used in capture mode.

I have been trying to interface the PWM based max6672 sensor with the PWM capture pin. I want to read the both the low time and high time of the PWM pulse. I am recieving an interrupt when the PWm input is received. But some how I am not able to calculate the rise and fall time correctly. I need this info to calculate the temperature of the sensor.

PCLKSEL0_bit.PCLK_PWM0 = 1; Can this be also used to set the pclk divisor for the capture input or is it only for PWM funactionality.

I want to use this PCAP0.0 pin as a counter. In the datasheet we have to set the
    PWM0CTCR_bit.CM = 0;      
    PWM0CTCR_bit.CIS = 1; to enable the rising edge counter mode one needs to set this pin.

And if the counter mode is enabled the pins @CCR as must be 000 as set. ref UM10237 datasheet pg 643

    PWM0CCR_bit.CAP0RE  = 0;   //capture of rising edge
    PWM0CCR_bit.CAP0FE  = 0;   //disable falling edge capture
    PWM0CCR_bit.CAP0INT = 0; //enable interrupt rising edge

But when I do this setting i am not receiving an interrupt from the sensor.

But if I set the PCAP0.0 pin as a timer
PWM0CTCR_bit.CM = 0;      
PWM0CTCR_bit.CIS = 0; and CCR for rising edge 0x5 and falling edge 0x6

    PWM0CCR_bit.CAP0RE  = 1;   //capture of rising edge
    PWM0CCR_bit.CAP0FE  = 0;   //disable falling edge capture
    PWM0CCR_bit.CAP0INT = 1; //enable interrupt rising edge 0x5
later I change in the interrupt to 0x6 for falling edge I am able to detect the interrupt but the counter doesnt have the correct values.

Is there something wrong in my understanding of the code?Can someone clear this for me?