NRF52840 dongle 10 button USB HID with zephyr

Goodday

 I thought this could be good learning curve to get started with Zephyr. Im having some problems with the GPIO.  If I rewrite this code for  3 buttons with  PORT1 (pin 1.10 pin 1.13 and pin 1.15) the code works. But it does not work on PORT 0 with 10 buttons. I presume it may be something with the DTS file that may be configuring the ports for other purposes (SPI/UART/I2C) etc. 

1. How do I use PORT 0 in zephyr instead of port 1.

2. is there anything I need to reconfigure in the DTS file to make it work.

Any help appreciated as always

Parents
  • Hi,

    Have you connected a debugger and checked if the program asserts or enters the callback handler?

    If I rewrite this code for  3 buttons with  PORT1 (pin 1.10 pin 1.13 and pin 1.14) the code works. But it does not work on PORT 0 with 10 buttons.

    But does it work with 3 buttons on PORT 0 or even 1?

    Also some of the GPIOs that you're trying to use are already in use in the Dongle dts,

    regards

    Jared 

  • HI Jared

    If I only declare 3 pins namely 10,13,15 the switches do work, but only port 1. One of my questions was how do I select PORT 0 so I can test the pins currently defined in the code. Ideally, I would like to make the entire PORT 0, GPIO inputs for buttons.

    You're right some of the GPIOs are declared in the DTS that's why I asked if I need to reconfigure it somehow.

    Thanks for the help

  • Hi,

    Ideally, using PORT 0 shouldn't be much difference than using PORT 1. Contrary to nRF5SDK, In zephyr we have something that we call the device tree that is used to describe the HW that the application will run on. Additional GPIOs that you're going to use should be added in an overlay which will map the pins in the device tree.  For example, here is an example on how to set interrupt on button1 (port 0, pin11)  on the nRF52840 DK so that LED1 will flash every time it's pressed:

    You can try to build this project with your dongle, and first add 1 or 2 gpios with an overlay, and repeat the steps that I did for the button for the additional gpios that you've added. Then eventually you can try to expand it to 10 buttons,

    I also strongly suggest to go through our DevAcademy, the first lessons are very relevant for your question Slight smile,

    regards

    Jared

  • Thanks Jared. 

    I have done an overlay file as per below. I see in the overlay file some of my pins say "&GPIO already assigned to 2 other nodes"  I dont think im removing SPI,I2C and UART nodes correctl

  • Hi,

    That looks correct, did you do a pristine build?

    If you're using nRF Connect SDK VS Code extension, then there is a DTS GUI that will make it easier for you to map out the pins and replace and delete properties. Maybe you could try and see if that helps?

    regards

    Jared

Reply
  • Hi,

    That looks correct, did you do a pristine build?

    If you're using nRF Connect SDK VS Code extension, then there is a DTS GUI that will make it easier for you to map out the pins and replace and delete properties. Maybe you could try and see if that helps?

    regards

    Jared

Children