I am using S12ZVML128 controller.
I want to calculate duty cycle on capture pin using single interrupt.
Please tell me if the code is available for the same?
Please refer to the attached example. You can measure using a single channel.
But you need also an interrupt in case the timer overflows.
I referred and implemented the same in my code.
But value of duty cycle is not consistent and it is getting changed so it is affecting the motor rotation.
I am not getting the exact issue in code why duty cycle gets changed?
How the value of MAX_OVERFLOW=500 is decided?
I used same sample code,I have given lowest priority for Timer Channel 0 interrupt.
Please provide me solution for the same?
I’m not sure I understand your question. The duty cycle result is changing while your input signal is stable? Why did you set Timer Channel 0 interrupt with lowest priority?
Regarding MAX_OVERFLOW, whenever an edge is detected the overflow counter is cleared. If there is no edge that could be detected the overflow counter increases until it reaches an arbitrary high number (500) after which we can say the signal is not periodic. So, the duty cycle is then 100% or 0% based on the input state (PTIT_PTIT0).
Retrieving data ...