How do you do Now need pwm_driver demo5 duty ratio, is there any way to 1/6 or 1/8?PWM and phase difference is 4 road? Ask for a few days, change seq_values [], but how to change?Try to success.
How do you do Now need pwm_driver demo5 duty ratio, is there any way to 1/6 or 1/8?PWM and phase difference is 4 road? Ask for a few days, change seq_values [], but how to change?Try to success.
Hi,
What PWM frequencyand duty cycle[%] do you want to set?
PS: You don't have to create a new question, you can add a comment here.
Click on "add a comment"
How do you do Is the need to change the duty ratio, demo5 duty ratio here is 1/4 and the phase difference, want to change duty ratio, here because there is phase, Nordic PWM phase is not easy to implement.
You will need to change the seq_values[] to change the duty ratio. The .top_value in your code is 15625.
E.g. for channel 0 (pin 2 in your code), you will need OR the 0x8000
with 7812 (.top_value/2), to get 1/8 duty ratio:
static nrf_pwm_values_individual_t /*const*/ seq_values[] =
{
{ 0x8000 | 7812 , 0, 0, 0 },
{ 0, 0x8000, 0, 0 },
{ 0, 0, 0x8000, 0 },
{ 0, 0, 0, 0x8000 }
};
To get 1/6 ratio, you need to use 15625/3 = 5208:
static nrf_pwm_values_individual_t /*const*/ seq_values[] =
{
{ 0x8000 | 5208 , 0, 0, 0 },
{ 0, 0x8000, 0, 0 },
{ 0, 0, 0x8000, 0 },
{ 0, 0, 0, 0x8000 }
};
The 0x8000
is here used to set bit 15 to 1, in order to invert the PWM output. See this post.
How do you do If the value is "15625" how to set the duty ratio of the change, according to set the bluetooth communication. Top_value, then the static nrf_pwm_values_individual_t const / * * / seq_values [] will follow change, how to set?
If you want to change/update the seq_values you can use the function nrf_drv_pwm_sequence_values_update() with a new pointer to the new duty cycle values(nrf_pwm_values_individual_t
)