This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why isn't my PPI/SPI channel triggered with GPIOTE?

Hello,

I would like to detect a change in a pin(GPIO_IN_NUMBER) and depending on it I would like to trigger a SPI transaction, this should happen through PPI.

So far I have configured my PPI in this way, is there something faulty on this setting?

thanks in advance!

nrf_drv_gpiote_in_config_t configHighToLow = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
configHighToLow.sense = GPIOTE_CONFIG_POLARITY_HiToLo;

//Initializing GPIO_IN_NUMBER with the above configurations   
err_code = nrf_drv_gpiote_in_init(GPIO_IN_NUMBER, &configHighToLow,gpio_event_handler);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_alloc(&ppi_channel_HighToLow);
APP_ERROR_CHECK(err_code);

gpiote_Transition_task_addr = nrf_drv_gpiote_in_event_addr_get(GPIO_IN_NUMBER);


spi_start_evt = nrf_drv_spi_start_task_get(&spi);

err_code = nrf_drv_ppi_channel_assign(ppi_channel_HighToLow, spi_start_evt, gpiote_Transition_task_addr);
APP_ERROR_CHECK(err_code);

 // Enable both configured PPI channels
 err_code = nrf_drv_ppi_channel_enable(ppi_channel_HighToLow);
 APP_ERROR_CHECK(err_code);

 nrf_drv_gpiote_in_event_enable(GPIO_IN_NUMBER,false);
  • Hi,

    I see three things:

    1. You need to enable GPIOTE with nrf_drv_gpiote_init(); at the top of your code.
    2. You need to enable the internal pullup resistor with configHighToLow.pull = NRF_GPIO_PIN_PULLUP;. Otherwise the pin might always be low.
    3. You have probably confused yourself with the naming of your variables. gpiote_Transition_task_addr is the event when you push the button. spi_start_evt is the task to start the SPI transfer. So if you switch these two variables in nrf_drv_ppi_channel_assign() it should work.
Related