Hello! I need to start a sequence of 26 pulses after getting low level signal on gpiote pin. I can do it in gpiote event handler but I need it most of the time so I want to use ppi for that here is my code:
nrf_ppi_channel_t ppi_channel;
nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);
uint16_t /*const*/ seq_values[] ={1};
nrf_pwm_sequence_t const seq =
{
.values.p_common = seq_values,
.length = NRF_PWM_VALUES_LENGTH(seq_values),
.repeats = 0,
.end_delay = 0
};
void in_data_handler (nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
//nrf_drv_pwm_simple_playback (&m_pwm0, &seq, 10, NRF_DRV_PWM_FLAG_STOP);
}
void HX711_init(uint8_t pin_number)
{
nrf_drv_gpiote_init();
nrf_drv_gpiote_in_config_t in_data_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
in_data_config.pull = NRF_GPIO_PIN_PULLUP;
nrf_drv_gpiote_in_init (HX_DATA, &in_data_config, in_data_handler);
nrf_drv_gpiote_in_event_enable(HX_DATA, true);
uint32_t err_code;
nrf_drv_pwm_config_t const config0 =
{
.output_pins =
{
pin_number, // 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
},
.base_clock = NRF_PWM_CLK_2MHz,
.count_mode = NRF_PWM_MODE_UP,
.top_value = 2,
.load_mode = NRF_PWM_LOAD_COMMON,
.step_mode = NRF_PWM_STEP_AUTO
};
err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_ppi_init();
nrf_drv_ppi_channel_alloc (&ppi_channel);
nrf_drv_ppi_channel_assign (ppi_channel,nrf_drv_gpiote_in_event_addr_get(HX_DATA), nrf_drv_pwm_task_address_get(&m_pwm0, NRF_PWM_TASK_SEQSTART1));
nrf_drv_ppi_channel_enable(ppi_channel);
}
The problem is I can't understand what kind of task should I use for ppi working like nrf_drv_pwm_simple_playback
function