2017-05-13 06:23 PM
How can i read an incoming PWM singal coming from my rc receiver ?? i kept searching and i found something called input capture but i couldn't understand it ?? so i will be glad if you can provide me an example.
2017-05-14 05:51 AM
Timer is free running, say counting up and then overflows back to 0x0000.
From this timer counting value, are up to 4 registers you control: The compares.
Either you program a value (say 0x4000) and connect it to a GPIO as OUTPUT compare to make PWM with 25% duty cycle, or you connect a GPIO input and a chosen edge will take a snapshot of the timer instant value and save it in the compare register (usually triggering an interrupt) for you to use this captured value. This is the INPUT capture mecanism.
So to measure a PWM, you can use input captures to capture rising/falling edge time and deduct the period, high and low time of the incoming signal.
2017-05-14 07:23 AM
Also PWM Input mode, SPL and HAL have examples, and examples for servo reading have also been published to the forum. A brief search should yield some on-point threads.
2017-05-16 03:21 AM
2017-05-16 07:01 AM
Faced similar problem a while ago. Not sure why your code doesn't work, but in my case it was due to improper counting unit reset procedure: counting unit was running whithout reset, and therefore I got random numbers all the time.
So, what I did to get it fixed:
- use the Slave Reset mode feature on rising edge: it automatically resets counting unit to zero when a new pulse arrives
- configured two IC channels, 1st for rising edge direct TI and another one for falling edge indirect TI.
How it works:
Rising edge of a new pulse resets counting unit to zero, then falling edge of this pulse triggers IC of channel 1. Rising edge of next pulse triggers IC of channel 2 and again resets counting unit - starts new cycle. You would only need to handle IC channel 2 interrupts and get values of both IC channels. Channel 1 value will reflect pulse width, channel 2 - duty cycle width.
2017-05-16 11:16 AM
TIM1 is an Advanced Timer, you need additional configuration fields that need to be populated. You'd also need TIM_CtrlPWMOutputs(TIM1, ENABLE);
Missing code here, but the values would need to be in uint16_t for the maths to work properly.
2017-05-16 05:28 PM
I will give it a try.
2017-05-16 05:30 PM
I did this in TIM4 but i got mixed up values, like when i try to separate data thay are all affecting the first value. Today i will provide you with a screenshot of this.
2017-05-17 03:38 AM