Hello
I only used PWM_library, but this is my first time using PWM_driver.
Simply controlling the duty cycle of multiple channels has been successful, but I am not sure about frequency control yet.
I found out that the Prescaler value can be changed through 'base_clock' in the code below. But I don't know where to modify the period.
static void pwm_init(void)
{
uint32_t err_code;
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
test_pwm, // channel 0
NRF_DRV_PWM_PIN_NOT_USED, // channel 1
NRF_DRV_PWM_PIN_NOT_USED, // channel 2
NRF_DRV_PWM_PIN_NOT_USED // channel 3
},
.irq_priority = APP_IRQ_PRIORITY_LOWEST,
.base_clock = NRF_PWM_CLK_4MHz, //Prescaler change
.count_mode = NRF_PWM_MODE_UP,
.top_value = m_top,
.load_mode = NRF_PWM_LOAD_INDIVIDUAL,
.step_mode = NRF_PWM_STEP_AUTO
};
err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
APP_ERROR_CHECK(err_code);
// m_used |= USED_PWM(0);
// This array cannot be allocated on stack (hence "static") and it must
// be in RAM (hence no "const", though its content is not changed).
}
May I know about this?
Thank you.