STMicroelectronics / STM32CubeWB

Full Firmware Package for the STM32WB series: HAL+LL drivers, CMSIS, BSP, MW, plus a set of Projects (examples and demos) running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits).
https://www.st.com/en/embedded-software/stm32cubewb.html
Other
227 stars 138 forks source link

BLE HeartRateMonitor FREERTOS notify problem #28

Closed KMeldgaard closed 3 years ago

KMeldgaard commented 3 years ago

Dear ST

I'm working on a custom board, trying to adapt the BLE_HeartRateFreeRTOS to work on a STM32WB55CEU6. So far i have been able to discover and connect to the MCU and call the characteristics in the Heart Rate service:

I can see the MCU does receive the HRS_NOTIFICATION_ENABLED/DISABLED notifications, as I'm able to toggle an LED in this callback. It seems like the HW-timer does not run properly. NOTE: the MCU does not crash, it just doesn't notify the client.

Describe the set-up

Additional context Below is the void HRS_Notification(HRS_App_Notification_evt_t *pNotification) implementation:

void HRS_Notification(HRS_App_Notification_evt_t *pNotification) {
    /* USER CODE BEGIN HRS_Notification_1 */

    /* USER CODE END HRS_Notification_1 */
    switch (pNotification->HRS_Evt_Opcode) {
/* USER CODE BEGIN HRS_Notification_HRS_Evt_Opcode */

/* USER CODE END HRS_Notification_HRS_Evt_Opcode */
#if (BLE_CFG_HRS_ENERGY_EXPENDED_INFO_FLAG != 0)
        case HRS_RESET_ENERGY_EXPENDED_EVT:
            /* USER CODE BEGIN HRS_RESET_ENERGY_EXPENDED_EVT */
            HRSAPP_Context.MeasurementvalueChar.EnergyExpended = 0;
            HRSAPP_Context.ResetEnergyExpended = 1;
            /* USER CODE END HRS_RESET_ENERGY_EXPENDED_EVT */
            break;
#endif

        case HRS_NOTIFICATION_ENABLED:
            /* USER CODE BEGIN HRS_NOTIFICATION_ENABLED */
            /**
             * It could be the enable notification is received twice without the disable notification in between
             */

            HW_TS_Stop(HRSAPP_Context.TimerMeasurement_Id);
            HW_TS_Start(HRSAPP_Context.TimerMeasurement_Id, HRSAPP_MEASUREMENT_INTERVAL);
            led1_blink_delay = 100;
            /* USER CODE END HRS_NOTIFICATION_ENABLED */
            break;

        case HRS_NOTIFICATION_DISABLED:
            /* USER CODE BEGIN HRS_NOTIFICATION_DISABLED */
            led1_blink_delay = 500;
            HW_TS_Stop(HRSAPP_Context.TimerMeasurement_Id);
            /* USER CODE END HRS_NOTIFICATION_DISABLED */
            break;

#if (BLE_CFG_OTA_REBOOT_CHAR != 0)
        case HRS_STM_BOOT_REQUEST_EVT:
            /* USER CODE BEGIN HRS_STM_BOOT_REQUEST_EVT */
            *(uint32_t *)SRAM1_BASE = *(uint32_t *)pNotification->DataTransfered.pPayload;
            NVIC_SystemReset();
            /* USER CODE END HRS_STM_BOOT_REQUEST_EVT */
            break;
#endif

        default:
            /* USER CODE BEGIN HRS_Notification_Default */

            /* USER CODE END HRS_Notification_Default */
            break;
    }
    /* USER CODE BEGIN HRS_Notification_2 */

    /* USER CODE END HRS_Notification_2 */
    return;
}

Screenshots Screenshot of clock config (sorry for poor resolution): image

Regards.

KMeldgaard commented 3 years ago

Moved the problem to https://community.st.com/s/question/0D53W00000sqph1SAA/ble-heartratemonitor-freertos-notify-problem