Hi,
I am using a PWM to control the output of an LED driver and I am implementing a soft_on function when powering ON the driver, so we have a start_PWM function that looks like this:
static void start_PWM(void)
{
// PWM stuff
app_pwm_config_t m_pwm0_config = APP_PWM_DEFAULT_CONFIG_1CH(1000, LIGHT_FIXTURE);
m_pwm0_config.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
uint32_t status = app_pwm_init(&PWM0, &m_pwm0_config, NULL);
APP_ERROR_CHECK(status);
m_pwm0_max = app_pwm_cycle_ticks_get(&PWM0);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "PWM max ticks: %d\n", m_pwm0_max);
app_pwm_enable(&PWM0);
nrf_delay_us(850);
//this is the soft on:
for(uint16_t i = 0; i < 300; i++)
{
//(void) app_pwm_channel_duty_ticks_set(&PWM0, 0, i);
while (app_pwm_channel_duty_ticks_set(&PWM0, 0, i) == NRF_ERROR_BUSY);
nrf_delay_ms(1);
__LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, "Current dimming: %d\n", i);
}
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Soft ON\n");
}
Now, the issue is that there is an initial pulse when powering ON and before the soft on happens. we also tried just simply to set to 0 with:
static void start_PWM(void)
{
// PWM stuff
app_pwm_config_t m_pwm0_config = APP_PWM_DEFAULT_CONFIG_1CH(1000, LIGHT_FIXTURE);
m_pwm0_config.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
uint32_t status = app_pwm_init(&PWM0, &m_pwm0_config, NULL);
APP_ERROR_CHECK(status);
m_pwm0_max = app_pwm_cycle_ticks_get(&PWM0);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "PWM max ticks: %d\n", m_pwm0_max);
app_pwm_enable(&PWM0);
nrf_delay_us(850);
(void) app_pwm_channel_duty_ticks_set(&PWM0, 0, 0);
}
But still, there is that initial pulse. We had a similar issue few weeks ago with this thread: https://devzone.nordicsemi.com/f/nordic-q-a/41616/initial-pulse-while-starting-a-pwm-application we thought that we solved but now we have it again...
and just to clarify, if we don't set anything after the enable function then there is no pulse:
static void start_PWM(void)
{
// PWM stuff
app_pwm_config_t m_pwm0_config = APP_PWM_DEFAULT_CONFIG_1CH(1000, LIGHT_FIXTURE);
m_pwm0_config.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
uint32_t status = app_pwm_init(&PWM0, &m_pwm0_config, NULL);
APP_ERROR_CHECK(status);
m_pwm0_max = app_pwm_cycle_ticks_get(&PWM0);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "PWM max ticks: %d\n", m_pwm0_max);
app_pwm_enable(&PWM0);
}
is there any reason to have that pulse when setting the PWM output?
I am using 15.2.0 SDK and 3.0.0 Mesh SDK.