If I use PWM "nrf_drv_pwm_simple_playback" and that will go to "start_playback"
How can I catch end point after it finish entire function?
BTW, the process will keep about 10 sec
Thank you!
static nrf_pwm_values_individual_t seq0_values[]={
...
};
nrf_pwm_sequence_t const seq0 = {
.values.p_individual = seq0_values,
.length = NRF_PWM_VALUES_LENGTH(seq0_values),
.repeats = 300,
.end_delay = 0
};
nrf_drv_pwm_simple_playback(&m_pwm0, &seq0, 1, NRF_DRV_PWM_EVT_FINISHED);
edit
Frøysa Sir,
Your solution is for simple sequence, and I have to use muti pwm mode, like this
void whiteTenSec(void)
{
if (m_used & USED_PWM(0))
{
nrf_drv_pwm_uninit(&m_pwm0);
}
printf("whiteTenSec \r\n");
enum{
TOP = 255,
STEP_COUNT = 25,
TIMES = 200
};
uint32_t err_code;
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
pin12 | NRF_DRV_PWM_PIN_INVERTED, // channel 0 B
pin13 | NRF_DRV_PWM_PIN_INVERTED, // channel 1 G
pin14 | NRF_DRV_PWM_PIN_INVERTED, // channel 3 R
NRF_DRV_PWM_PIN_NOT_USED
},
.irq_priority = APP_IRQ_PRIORITY_LOW,
.base_clock = NRF_PWM_CLK_125kHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = 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);
static nrf_pwm_values_individual_t seq0_values[]={
{0x80, 0x80, 0x80}
};
nrf_pwm_sequence_t const seq0 = {
.values.p_individual = seq0_values,
.length = NRF_PWM_VALUES_LENGTH(seq0_values),
.repeats = 5000,
.end_delay = 0
};
static nrf_pwm_values_individual_t seq1_values[]={
{0xff, 0xff, 0xff}
};
nrf_pwm_sequence_t const seq1 = {
.values.p_individual = seq1_values,
.length = NRF_PWM_VALUES_LENGTH(seq1_values),
.repeats = 1,
.end_delay = 0
};
nrf_drv_pwm_complex_playback(&m_pwm0, &seq0, &seq1, 1, NRF_DRV_PWM_EVT_FINISHED);
}
and
void blinkyRed(void)
{
if (m_used & USED_PWM(0))
{
nrf_drv_pwm_uninit(&m_pwm0);
}
enum{
TOP = 255,
STEP_COUNT = 255,
TIMES = 10
};
uint32_t err_code;
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
pin12 | NRF_DRV_PWM_PIN_INVERTED, // channel 0 B
pin13 | NRF_DRV_PWM_PIN_INVERTED, // channel 1 G
pin14 | NRF_DRV_PWM_PIN_INVERTED, // channel 2 R
NRF_DRV_PWM_PIN_NOT_USED
},
.irq_priority = APP_IRQ_PRIORITY_LOW,
.base_clock = NRF_PWM_CLK_125kHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = 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);
static nrf_pwm_values_individual_t seq0_values[]={
{0xff,0xff,0x80},
{0xff,0xff,0x80},
{0xff,0xff,0x80},
{0xff,0xff,0x80},
{0xff,0xff,0x80}
};
static nrf_pwm_values_individual_t seq1_values[]={
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff}
};
nrf_pwm_sequence_t const seq0 = {
.values.p_individual = seq0_values,
.length = NRF_PWM_VALUES_LENGTH(seq0_values),
.repeats = 50,
.end_delay = 1
};
nrf_pwm_sequence_t const seq1 = {
.values.p_individual = seq1_values,
.length = NRF_PWM_VALUES_LENGTH(seq1_values),
.repeats = 50,
.end_delay = 1
};
nrf_drv_pwm_complex_playback(&m_pwm0, &seq0, &seq1, 1, NRF_DRV_PWM_FLAG_LOOP);
}
}
I want to see the situation is: white 10s -> red blink
but there is: white 1s -> redblink
Thanks again for your help...