I wanna measure PWM signal duty cycle with STM8S Capture Module. PWM signal duty is changing between 0% and 100%. System start 0%, 100% or any value between 0% and 100%.
I'm using capture interrupt and I'm measuring exact value of PWM duty. But I have a problem. If the system will start at 0% or %100, I can't handle that value. Because there isn't any changes of signal edge.
I have an idea. I can use one extra I/O port to control signal level. But I wanna ask you first, is there any software solution without using I/O pin ? Could we know capture pin level (high or low) ?
I haven't solved this problem yet. I tired to read IDR state before I asked here.
I used GPIO_ReadInputPin function. I used TIM1 Channel 1 so it is PC1 pin. GPIO_ReadInputPin(GPIOC, GPIO_PIN_1) function returns 0 when the PWM signal is 0% and 0x02 when the PWM signal is 100%. It should be 1 when the PWM signal is 100%, doesn't it ?
First of all, thanks for your help. Yes, you are right. I figured out now. I was wrong because I used this code to check capture pin and It didn't work.