Hi,
I'm starting a proyect with this microcontroller.
In that proyect I need to set a PWM and read a different one duty cycle's. Is that prossible with this model?
I have found that to generate the PWM signal I have to use the TMR0 output, but there is only one Timer I/O avaible and I dont know if there is other way to measurement the duty cycle.
Thank you in advance,
Raúl.
Solved! Go to Solution.
Hi,
I will give you a thougnt to measure the duty. Configure a gpio as a external interrupt source. The rising edge and falling edge is active. When the PWM's rising edge comes, we start the PIT. When the PWM's falling edge comes, we stop the PIT. Calculate the difference. Then the results is multiplied by the PIT's period. It is the high level duration. If you set the gpio that the rising edge only is active, you will get the PWM's period. We have the high level duration and PWM's period. Then we can calculate the duty.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
I will give you a thougnt to measure the duty. Configure a gpio as a external interrupt source. The rising edge and falling edge is active. When the PWM's rising edge comes, we start the PIT. When the PWM's falling edge comes, we stop the PIT. Calculate the difference. Then the results is multiplied by the PIT's period. It is the high level duration. If you set the gpio that the rising edge only is active, you will get the PWM's period. We have the high level duration and PWM's period. Then we can calculate the duty.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thanks you so much for your reply.
How do I know which pins have an interrupt? I have found in the manual the register to configure it and it seems that not all input support that function.
How do I know which pins support it?
Thanks you in advance,
Raúl.
Hi,
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------