priyanki vashi wrote:
> Hello Jack ,
>
> I am interested to see the code you have to generate 50& duty cycle.
> Is it possible to share for you ?
>
> Thanks // Priyanki
Hi,
You can simply modify this following code:
1 | // Set the compare triggers.
|
2 | tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0600); // Set RA value.
|
3 | tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x2000); // Set RC value.
|
Here just change the values of RA and RC to get the required duty cycle.
If you use the same values for RA and RC you will get the same duty
cycle but then the frequency will be divided by half. To keep the
frequency intact, the value of RC should be much much higher. Try the
following code to get 50% duty cycle with the same frequency.
1 | // Set the compare triggers.
|
2 | tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0500); // Set RA value.
|
3 | tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x8500); // Set RC value.
|
Hope this answers your question.
Regards,
Jack