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

GPIOTE example how can i modify to pulse once and why dont I get time event

Uisng   pca10040 and SDk16.0.0 + Segger

I built and ran the GPIOTE example so I could experiment.

I want to toggle a gpio once only and then stop and I need to know when its complete.

So I changed   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK to NRF_TIMER_SHORT_COMPARE0_STOP_MASK in the function led_blinking_setup() and expected to get one toggle event on the GPIO for the specified period and expected to see the    timer_dummy_handler(nrf_timer_event_t event_type, void * p_context)  called.

On my scope I see the GPIO go high but not low and I dont get the timer event.

What am i missing how do i set it up to toggle once and then get an event when its complete so I know

Robin

Parents
  • Hi Robin, 

    in the GPIOTE example the Timer is configured in the extended compare mode using nrfx_timer_extended_compare. The last parameter passed to nrfx_timer_extended_compare is the boolean value enable_int, which dictates if the the interrupt for the compare channel is enabled or disabled.

    In the example nrfx_timer_extended_compare is called with int_enable set to false

     nrf_drv_timer_extended_compare(&timer, (nrf_timer_cc_channel_t)0, 200 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);

    So If you want the TIMER IRQ, i.e. timer_dummy_handler to be called on every compare event, then you just need to alter the line to 

    nrf_drv_timer_extended_compare(&timer, (nrf_timer_cc_channel_t)0, 200 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    In order to have the GPIO go high and then low again, you will need to have two COMPARE0 event. In the GPIOTE context, toggleing a GPIO means that it will go from low to high if the pin is low or high to low if the pin is high. Hence, the TOGGLE task of the GPIO must be triggered twice for the GPIO to go back to the initial state. 

    Lastly, there is no event generated when a GPIO state is set, so if you want to verify that the pin went high or low, then you need to check this in the interrupt handler of the event that triggered the Toogle task, which in this case is the TIMER IRQ handler, i.e. timer_dummy_handler. 

    However, the whole point with the GPIO task and event system and PPI is that you're able to trigger task without any CPU execution. 

    Best regards

    Bjørn

Reply
  • Hi Robin, 

    in the GPIOTE example the Timer is configured in the extended compare mode using nrfx_timer_extended_compare. The last parameter passed to nrfx_timer_extended_compare is the boolean value enable_int, which dictates if the the interrupt for the compare channel is enabled or disabled.

    In the example nrfx_timer_extended_compare is called with int_enable set to false

     nrf_drv_timer_extended_compare(&timer, (nrf_timer_cc_channel_t)0, 200 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);

    So If you want the TIMER IRQ, i.e. timer_dummy_handler to be called on every compare event, then you just need to alter the line to 

    nrf_drv_timer_extended_compare(&timer, (nrf_timer_cc_channel_t)0, 200 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    In order to have the GPIO go high and then low again, you will need to have two COMPARE0 event. In the GPIOTE context, toggleing a GPIO means that it will go from low to high if the pin is low or high to low if the pin is high. Hence, the TOGGLE task of the GPIO must be triggered twice for the GPIO to go back to the initial state. 

    Lastly, there is no event generated when a GPIO state is set, so if you want to verify that the pin went high or low, then you need to check this in the interrupt handler of the event that triggered the Toogle task, which in this case is the TIMER IRQ handler, i.e. timer_dummy_handler. 

    However, the whole point with the GPIO task and event system and PPI is that you're able to trigger task without any CPU execution. 

    Best regards

    Bjørn

Children
No Data
Related