Hi everyone,i 've a question about this component, i need measure the pulse width (high) of a input PWM, i thought that setting it with rise edge, this component would return a value (in miliseconds) of measured,pulse width,but, when i display this value returned by this component, i get a wrong value, for example, if the input PWM is simetric 50Hrz (duty of 50 %) the capture component return 38000, what is 38000?¿ i want a periode of PWM (it whould be 20000 milisecond, not 38000) i don't understand why Capture component return a number that doesn't corresponds with a periodic of input PWM, it would be 20000 miliseconds.
My microcontroller is MKE04Z128, i show you my code, by the way, when i create a Capture component, i get this message: "The component "Capture_LDD" uses another shared component for item "Linked TimerUnit". You can use existing component or create a new one., i select "New component [Kinetis/TtimerUnit], its same select a existing timer?¿, this is my Capture component configuration,
- Capture Device: FTM0_C0V
- Capture input pin: some pin correspond 0 channel
- Edge:rising edge
- Maximum time of event:87 ms (What does it mean??)
This is my code:
Main.c
uint16_t data = 0;
Cap1_Reset();
for(;;){
Display(data);
}
Events.c
extern uint16_t data:
Cap1_OnCapture(){
Cap1_GetCaptureValue(&data);
Cap1_Reset();
}
Thanks so much again!
Hi Ricard Comas,
TU1_GetCaptureValue just return the value of FTMx_CnV.
Please try to use the Init_PWT, you can find the Pulse Width Timer (PWT) module in Reference Manual.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------