sns22
Member level 2
- Joined
- Jan 15, 2011
- Messages
- 46
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Spain
- Activity points
- 1,708
Hi.
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
And if the counter mode is enabled the pins @CCR as must be 000 as set. ref UM10237 datasheet pg 643
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
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?
Regards
Sns
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
Code C - [expand] 1 2 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
Code C - [expand] 1 2 3 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
Code C - [expand] 1 2 3 4 5 6 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?
Regards
Sns
Last edited by a moderator: