Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hardfault in FreeRTOS button code

Hello All,

I have taken usbd_ble_uart_freertos example and modified it for USB MIDI example (taken from Github) for nRF5 SDK and modified it to use nRF52833 SoC.

I am using Segger Embedded Studio on Windows 10 PC and EVK of ublox having NINA-B406 MCU.

USB MIDI is working fine until I press any button on the EVK. Code executes for button event and MIDI message is sent to PC Music application over USB and I can see the change accordingly in PC Music application. But after that the code resets - I can see in device manager is refreshed whenever I press any of the two buttons configured in the code.

Below is the part of code for UBS thread:

// Enter main loop.
for (;;)
{
    /* Waiting for event */
    UNUSED_RETURN_VALUE(ulTaskNotifyTake(pdTRUE, USB_THREAD_MAX_BLOCK_TIME));
    while (app_usbd_event_queue_process())
    {
        /* Nothing to do */
        NRF_LOG_INFO ("USB event processed");
    }
}

I debugged the code and found that app_usbd_event_queue_process () is completed successfully when button is pressed, but after that when it goes  to execute

   UNUSED_RETURN_VALUE(ulTaskNotifyTake(pdTRUE, USB_THREAD_MAX_BLOCK_TIME));

line. In this function when 

   taskEXIT_CRITICAL();

instruction is executed after that the debug shows "Unknown function at 0x00000A06".

After that it shows Hardfault error.

for Button, I have used below code:

   ret = bsp_init(BSP_INIT_BUTTONS, bsp_event_handler);

   UNUSED_RETURN_VALUE(bsp_event_to_button_action_assign(BSP_BOARD_BUTTON_0,
   BSP_BUTTON_ACTION_RELEASE,
   BTN_MIDI_KEY_0_RELEASE));

Button press event is detected and it goes to execute bsp_event_handler

Any help / guide to resolve this crash?

Or is there any example of button with FreeRTOS? it will also be helpful as a starting point.

Regards.

Parents Reply Children
No Data
Related