SDK17.0.2+NRF52833
I use nrf52833 to do some thing, P1.09 and p0.11 as two pwm singals to drive two motor and P0.0 as a led pin (high made led light).
the code as following:
static void pwm0_init(void)
{
uint32_t err_code;
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
MOTOR_CTRL_PIN_0 | NRF_DRV_PWM_PIN_INVERTED, //P1.09
MOTOR_CTRL_PIN_1 | NRF_DRV_PWM_PIN_INVERTED, //P0.11
},
.irq_priority = APP_IRQ_PRIORITY_LOWEST,
.base_clock = NRF_PWM_CLK_500kHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = PWM_TOP_VALUE,
.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);
//board_light_red();
m_pwm_seq_values.channel_0 = 0;
m_pwm_seq_values.channel_1 = 0;
nrf_drv_pwm_simple_playback(&m_pwm0, &m_pwm_seq, 1, NRF_DRV_PWM_FLAG_LOOP);//why execute this, the P0.0 output high level.
}
void motor_ctrl_init(void)
{
uint8_t i = 0;
uint32_t motor_ctrls[] = MOTOR_PINS_LIST;
for (i = 0; i < MOTOR_CTRLS_NUMBER; i++)
{
nrf_gpio_cfg_output(motor_ctrls[i]);
nrf_gpio_pin_write(motor_ctrls[i],0);
}
pwm0_init();
NRF_LOG_DEBUG("%s return ok.\n", __FUNCTION__);
}
int main(void)
{
uint32_t err_code;
log_init();
NRF_LOG_INFO("apps start......");
motor_ctrl_init();
///...
}
I want light the LED after pwm init. but the led(connected P0.0)lighted before my code to output the p0.0 high level-when the pwm0_init function executed. It's not match my desire.
additional: Softdevice burninged(s140_nrf52_7.2.0_softdevice.hex)