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

How to use the SDK board support package with custom board having more than 8 button

I wanted to use the sdk board support file with coustom board having 13 buttons. I have modified the bsp.c and configer number of low power events and added a coustom header. However, it seems like the device reset rondomely when using sdk11 and on sdk 14 “Fatal:” log messge appers rondomey from app_error_fault_handler in app_error_weak.c file. How do i fix this, Is it worng to impliment morethan 8 button.

custom_board.h

Parents
  • Hello sami

    You say you have modified bsp.c? What changes have you made here? It should not be necessary to change bsp.c for a custom board. The board support module (bsp) uses the defines in sdk_config.h and in pca10028.h/pca10040.h /pca10056.h/custom_board.h, and as long as you provide it with one of the mentioned files with the appropriate defines it should work as intended.

    As you have tried SDK14 I assume you are using the nRF52 series?

    Are you only using low power events (low accuracy)? Do keep in mind the nRF51 supports a maximum of 4 GPIOTE channels (used for high accuracy), and the nRF52 has 8 channels.

    In your case you would add a custom_board.h, as well as the BOARD_CUSTOM preprocessor symbol define. The custom_board.h should contain a list of all the pins used for buttons and LEDS, just like they are in pca10040.h for nRF52832 DK as an example.

    Have you tried debugging to see what the error code is?

    EDIT 23.08.17

    To run the code with your custom_board.h I added the following lines to the definition of app_buttons[BUTTONS_NUMBER] in bsp.c

    #ifdef BSP_BUTTON_8
    {BSP_BUTTON_8, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_8
    #ifdef BSP_BUTTON_9
    {BSP_BUTTON_9, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_9
    #ifdef BSP_BUTTON_10
    {BSP_BUTTON_10, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_10
    #ifdef BSP_BUTTON_11
    {BSP_BUTTON_11, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_11
    #ifdef BSP_BUTTON_12
    {BSP_BUTTON_12, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_12
    

    In sdk_config.h I changed

    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
    #endif
    

    to

    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 13
    #endif
    

    And in the preprocessor symbol defines I added BOARD_CUSTOM and removed BOARD_PCA10040

    GPIOTE for the nRF52832 has 8 channels, however these are only used for high accuracy mode. The bsp module however initializes these buttons as low accuracy mode (gpiote low power) (PORT event). You can have more than 8 buttons in low accuracy, but you cannot detect simultaneous button presses.

    Best regards

    Jørn Frøysa

Reply
  • Hello sami

    You say you have modified bsp.c? What changes have you made here? It should not be necessary to change bsp.c for a custom board. The board support module (bsp) uses the defines in sdk_config.h and in pca10028.h/pca10040.h /pca10056.h/custom_board.h, and as long as you provide it with one of the mentioned files with the appropriate defines it should work as intended.

    As you have tried SDK14 I assume you are using the nRF52 series?

    Are you only using low power events (low accuracy)? Do keep in mind the nRF51 supports a maximum of 4 GPIOTE channels (used for high accuracy), and the nRF52 has 8 channels.

    In your case you would add a custom_board.h, as well as the BOARD_CUSTOM preprocessor symbol define. The custom_board.h should contain a list of all the pins used for buttons and LEDS, just like they are in pca10040.h for nRF52832 DK as an example.

    Have you tried debugging to see what the error code is?

    EDIT 23.08.17

    To run the code with your custom_board.h I added the following lines to the definition of app_buttons[BUTTONS_NUMBER] in bsp.c

    #ifdef BSP_BUTTON_8
    {BSP_BUTTON_8, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_8
    #ifdef BSP_BUTTON_9
    {BSP_BUTTON_9, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_9
    #ifdef BSP_BUTTON_10
    {BSP_BUTTON_10, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_10
    #ifdef BSP_BUTTON_11
    {BSP_BUTTON_11, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_11
    #ifdef BSP_BUTTON_12
    {BSP_BUTTON_12, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_12
    

    In sdk_config.h I changed

    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
    #endif
    

    to

    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 13
    #endif
    

    And in the preprocessor symbol defines I added BOARD_CUSTOM and removed BOARD_PCA10040

    GPIOTE for the nRF52832 has 8 channels, however these are only used for high accuracy mode. The bsp module however initializes these buttons as low accuracy mode (gpiote low power) (PORT event). You can have more than 8 buttons in low accuracy, but you cannot detect simultaneous button presses.

    Best regards

    Jørn Frøysa

Children
  • Hello Jørn,

    Yes am using nRF52832 soc,

    what i modified In bsp.c file is that , app_buttons[] configuration array definition, i added BSP_BUTTON_8 to BSP_BUTTON_12. Initially it was defined upto BSP_BUTTON_7. I did this with the intention of registering the additional 5 buttons used by the application. However, from your answer i understood that this is wrong. And it seems i am having the problem for this reason due to the limitation of GPIOTE.

    But i still didn’t find material to follow to setup the bsp for 13 buttons and receive button press even. As u pointed out i already did custom header (which i will past below for your reference), and the BOARD_CUSTOM macro. But clearly there must be something more i should do because the program crash if i just do this. U can try this for yourself easily. i am using SDK 14, HID keyboard example, nRF52-DK (yes i tried it on the DK also, in addition to the custom board),

    The error code, id = 0x4001, pc = 0x0, info = 0x200057C8

    This is from the app_error_fault_handler in app_error_weak.c file

  • Are you able to find out what function causes that error? I believe I will need to see your code to assess this any further. If your code is confidential you can create a mypage case at nordicsemi.com and refer to this case. If it isn't confidential you can just add your code as a .zip/.c/.h file to your original question.

  • Hey Jørn,

    Am having the issue on the SDK ble HID keyboard example. i have attached the header file to the original question. just use the header, on SDK 14 HID keyboard example. and you will see that the program stuck when bsp is initialized. However, if u set the number of buttons less than 8 the program works fine. also if u modify bsp.c as i mentioned previously (though it is completely wrong) and set GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS to 13., then the program runs for sometime but it will also throw the error (id = 0x4001, pc = 0x0, info = 0x20005760)

    So my question is how to use the board support package for 13 buttons or more and receive push events. The titorial mentions to configure GPIOTE handler (as i understood from you this is limited to 8 channels).

  • As it turns out you will indeed need to modify the app_buttons array in bsp.c, I apologize for this blunder on my part. I overlooked the fact that it lists defines for each individual button within the array, and I see now it is only designed to handle 8 buttons. By adding defines for the rest of the buttons similar to what is done for the first 8 buttons, and setting the number of GPIOTE low power events in sdk_config.h to 13 you should be able to run the program.

  • Hey Jørn,

    Have you try to run the code for yourself, i tried the setting as u explained. However, the program crash (i.e. go into app_error_fault_handler) at random time, with the error code:id = 0x4001, pc = 0x0, info = 0x20005760. Infact, this was my original question, I couldn't find out information about the error code.

    On the other hand what about the fact that GPIOTE module is limited to 8 channel, can i still use more than 8 buttons.

Related