I am using S132 in the Segger IDE on an nrf52832.
I am using SDK version 17.0.0_9d13099.
When I call sd_ble_gatts_hvx() from within a GPIOE ISR (externally pin triggered), at 100Hz, I can successfully send a packet.
But calling this ftn with the same parameters from within a Timer ISR, at the same rate, I get a Hard Fault.
Even sending a known packet crashes into a Hard Fault.
I have searched the Zone for similar issues but cannot seem to see a fix.
What could be the cause of this type of fault?
*
* Send a BLE Pkt to the selected connection
*
* Using SDK 17.0.0_9d13099
*
* Note: Called on a peripheral device
* p_cls points to the local structure with a connected BLE master
* p_data points to a static uint8_t buffer with a known data string
* p_length is correct for the TX pkt
* conn_handle is correct
*/
send_ble_pkt(ble_cls_t * p_cls,
uint8_t * p_data,
uint16_t * p_length,
uint16_t conn_handle)
{
ret_code_t err_code;
static ble_gatts_hvx_params_t hvx_params;
ble_cls_client_context_t * p_client;
VERIFY_PARAM_NOT_NULL(p_cls);
if ((p_cls->conn_handle == BLE_CONN_HANDLE_INVALID)
|| (p_cls->strm_handles.value_handle == BLE_GATT_HANDLE_INVALID)
|| !p_cls->trns_enable){
return NRF_ERROR_INVALID_STATE;
}
if (*p_length > BLE_CLS_MAX_DATA_LEN){
return NRF_ERROR_INVALID_PARAM;
}
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_cls->strm_handles.value_handle;
hvx_params.p_data = p_data;
hvx_params.p_len = p_length;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
return sd_ble_gatts_hvx(conn_handle, &hvx_params);
}