Hello,
I perform a test using a nrf52840 DK board in order to output a PWM at 50 Hz on a GPIO.
Here is the code:
void pwm_init(void)
{
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
NRF_DRV_PWM_PIN_NOT_USED,
2, // P0.2
NRF_DRV_PWM_PIN_NOT_USED,
NRF_DRV_PWM_PIN_NOT_USED
},
.irq_priority = APP_IRQ_PRIORITY_HIGHEST,
.base_clock = NRF_PWM_CLK_4MHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = 65535, // max possible
.load_mode = NRF_PWM_LOAD_INDIVIDUAL,
.step_mode = NRF_PWM_STEP_AUTO
};
APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, NULL));seq_values.channel_0 = 0;
seq_values.channel_1 = 32767; // 50% duty cycle
seq_values.channel_2 = 0;
seq_values.channel_3 = 0;
nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
}
Using this the output signal is unstable, it change for 49.5 to 49.6 Hz.
What could be the cause of this?
Thanks
Fabrice