Hi,
I am try to create a PWM output which can move the specified number of steps.
Please find following source code
uint32_t TotalMove = 0;
void pwm0_Manual_handler(nrf_drv_pwm_evt_type_t event_type)
{
#define StepCntInitial 2
static uint32_t StepCnt = 0/*MotorInitializeStep*/;
static uint8_t DebugPrint = 0;
TotalMove++;
if ( StepCnt-- == 0 )
{
StepCnt = StepCntInitial;
nrf_drv_pwm_stop(&m_pwm0, true);
}
return;
}
void PwmInit_ManualRun(void)
{
{ // Control PWM-0
nrf_drv_pwm_config_t const config =
{
.output_pins =
{
PwmOutputPin | NRF_DRV_PWM_PIN_INVERTED,
2 | NRF_DRV_PWM_PIN_NOT_USED,
30 | NRF_DRV_PWM_PIN_NOT_USED,
28 | NRF_DRV_PWM_PIN_NOT_USED
},
.irq_priority = APP_IRQ_PRIORITY_LOWEST,
.base_clock = NRF_PWM_CLK_16MHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = m_BaseFrequency,
.load_mode = NRF_PWM_LOAD_INDIVIDUAL,
.step_mode = NRF_PWM_STEP_AUTO
};
APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config, pwm0_Manual_handler));
m_pwm0_set_value.channel_0 = m_BaseFrequency/2;
m_pwm0_set_value.channel_1 = m_BaseFrequency/2;
m_pwm0_set_value.channel_2 = m_BaseFrequency/2;
m_pwm0_set_value.channel_3 = m_BaseFrequency/2;
(void)nrf_drv_pwm_simple_playback(&m_pwm0, &m_pwm0_seq, 1, NRF_DRV_PWM_FLAG_LOOP);
NRF_LOG_INFO("Use call-back: pwm0_Manual_handler");
}
}
After I execute above problem, I can get following wave form output.
First image is correct, and the second image is incorrect.
The second image include to many wave, but I only want send 2 waves output.
Would you please tell me how to fix this problem?
Thank you