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

GPIOTE IN Event not triggering PPI task

I am trying to time a capacitor discharge through different resistance sensors for greater resolution than an ADC. I did this using the GPIO functions initially but the SD will sometimes interfere and cause the readings to be off. I have decided to try this via PPI and I have it just about working. The only issue I am having is the GPIOTE IN event does not seem to be triggering the timer capture task. I can use the IN Event callback to manually capture the value which does work but I really want to do it via PPI to avoid interference from the SD. I have included an annotated example; hopefully I am just missing something really simple:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define TEMP_COMP_LINE 11
#define TEMP_THERM_LINE 12
#define TEMP_SENSE_LINE 13
// Use a counter so we can manually increment it and start the PPI chain
nrf_drv_timer_t start_counter = NRF_DRV_TIMER_INSTANCE(2);
// Timer for capacitor discharge
nrf_drv_timer_t discharge_timer = NRF_DRV_TIMER_INSTANCE(3);
// PPI Channels
nrf_ppi_channel_t ppi_1, ppi_2;
uint32_t line_discharge_time = 0;
void timer_event_handler(nrf_timer_event_t event_type, void * p_context){}
void sense_dummy_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
// Uncommenting this will allow timer capture on IN event!
//line_discharge_time = nrf_drv_timer_capture(&discharge_timer, NRF_TIMER_CC_CHANNEL0);
__NOP();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Using nRF5_SDK_12.2.0_f012efa with s132_nrf52_3.0.0_softdevice

Any ideas?

Thanks in advance,

Parents
  • FormerMember
    +1 FormerMember

    I would think the problem is that the GPIOTE event address is assigned to the PPI channel before the GPIOTE IN event is intialized. I would think you should do something like this:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // 1) Initialize the sense line (gpiote):
    // Initialize and enable then sense line (high to low)
    sense_cfg.pull = NRF_GPIO_PIN_NOPULL;
    nrf_drv_gpiote_in_init(TEMP_SENSE_LINE, &sense_cfg, sense_dummy_handler);
    // 2) Assign the initialized GPIOTE event to a PPI channel.
    // Configure a PPI channel to stop the discharge timer whenever a sense line goes low
    nrf_drv_ppi_channel_alloc(&ppi_2);
    nrf_drv_ppi_channel_assign(ppi_2,
    nrf_drv_gpiote_in_event_addr_get(TEMP_SENSE_LINE),
    nrf_drv_timer_task_address_get(&discharge_timer, NRF_TIMER_TASK_CAPTURE0));
    ....
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    Also, remember to check and handle all error codes! 

Reply
  • FormerMember
    +1 FormerMember

    I would think the problem is that the GPIOTE event address is assigned to the PPI channel before the GPIOTE IN event is intialized. I would think you should do something like this:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // 1) Initialize the sense line (gpiote):
    // Initialize and enable then sense line (high to low)
    sense_cfg.pull = NRF_GPIO_PIN_NOPULL;
    nrf_drv_gpiote_in_init(TEMP_SENSE_LINE, &sense_cfg, sense_dummy_handler);
    // 2) Assign the initialized GPIOTE event to a PPI channel.
    // Configure a PPI channel to stop the discharge timer whenever a sense line goes low
    nrf_drv_ppi_channel_alloc(&ppi_2);
    nrf_drv_ppi_channel_assign(ppi_2,
    nrf_drv_gpiote_in_event_addr_get(TEMP_SENSE_LINE),
    nrf_drv_timer_task_address_get(&discharge_timer, NRF_TIMER_TASK_CAPTURE0));
    ....
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    Also, remember to check and handle all error codes! 

Children
No Data