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

ncs zephyr example called 'nrfx'

ncs 1.5.1, using SES, the example for zephyr
samples/boards/nrf/nrfx/src/main.c
github URL:
github.com/.../main.c

does not work for me;
while the 'button_handler' gets called OK, the LED does not toggle.

And another compiler gives a WARNING on the call lines for n
  nrfx_gppi_channel_endpoints_setup 
due types mismatch!
I think its the last argument per 
nrfx_gpiote_in_event_get(OUTPUT_PIN) 
that should be of enum nrf_gpiote_task_t, but your code is passing an 'event' kind.
I tried to fix but still no LED toggle.

Please review this example.

Thanks!

  • C compilers do not check for enum type mismatch; In my case it is the additional CLang based verifier running. 

    I ask again, why should we code for an IN -event on a !OUTPUT! pin?
    nrfx_gpiote_in_event_get (OUTPUT_PIN)

    While looking at the nrfx implementation, I think it worked (for you) due pure coincidence as the offsets of the channels/registers are the same.

    Another point on this line is the mixture of nrfx_* vs nrf_* calls,
    I think it would be much better readable as:
      nrfx_gppi_channel_endpoints_setup(channel,
           nrfx_gpiote_in_event_addr_get(INPUT_PIN),
           nrfx_gpiote_out_task_addr_get(OUTPUT_PIN) );

  • IMPORTANT: another bad point for this example: it is VERY prone to button bounce!  (I think there was an app library in an [nrf5?] sdk exactly for this reason to provide debouncing). So this example (button to GPIOTE-in) has no serious use case. there should be a big red WARNING in the readme.

  • I wasted some more time on this example, then I found it only works exactly with all other 3 buttons/switches, BUT not with the 'Button 1' aka 'sw0'. The next observation was, with sw0 the 'button_handler()' function gets called TWICE per button press! (but only once for the 3 other buttons/switches). Thus I guess there is a zephyr config disaster.

  • Hi! I just spoke to the developer and there does seem to be a small copy-paste error in this sample. There will be a fix soon. 

    And you are correct in your observation, there is no debouncing used here as the purpose of this sample is to show how to use the nrfx drivers in Zephyr, not how to handle buttons reliably. 

    We unfortunately don't support the debouncing feature in NCS yet.

Related