Hard fault interrupt on ai_network_run( ) funtion.
Hi,
I created my own model and tried to import it into the STM32L476 MCU.
When I execute the ai_network_run( ) function, I got the hard fault interrupt.
Here is the function below.
( I refered the code from here :
https://wiki.st.com/stm32mcu/wiki/AI:How_to_perform_motion_sensing_on_STM32L4_IoTnode)
static void AI_Run(float *pIn, float *pOut)
{
ai_i32 batch;
ai_error err;
/* Update IO handlers with the data payload */
ai_input[0].data = AI_HANDLE_PTR(pIn);
ai_output[0].data = AI_HANDLE_PTR(pOut);
batch = ai_network_run(network, ai_input, ai_output);
if (batch != 1)
{
err = ai_network_get_error(network);
printf("AI ai_network_run error - type=%d code=%d\r\n", err.type, err.code);
Error_Handler();
}
}I have checked the 'ai_input' and 'ai_output' values and they all pointed well.
Here is the main loop.
while (1)
{
AccelReadValues(0x32, 6);
x = ((AccelData[1] << 8) | AccelData[0]);
y = ((AccelData[3] << 8) | AccelData[2]);
z = ((AccelData[5] << 8) | AccelData[4]);
ACC_Value_Raw.AccX = (x * .039);
ACC_Value_Raw.AccY = (y * .039);
ACC_Value_Raw.AccZ = (z * .039);
HAL_Delay(50);
aiInData[write_index++] = ACC_Value_Raw.AccX;
aiInData[write_index++] = ACC_Value_Raw.AccY;
aiInData[write_index++] = ACC_Value_Raw.AccZ;
// AI_NETWORK_IN_1_SIZE = (24 * 3 * 1)
if (write_index >= AI_NETWORK_IN_1_SIZE)
{
printf("Running inference\r\n");
AI_Run(aiInData, aiOutData);
/* Output results */
for (uint32_t i = 0; i < AI_NETWORK_OUT_1_SIZE; i++)
{
printf("%8.6f ", aiOutData[i]);
}
uint32_t class = argmax(aiOutData, AI_NETWORK_OUT_1_SIZE);
printf(": %d - %s\r\n", (int) class, activities[class]);
write_index = 0;
}
//MX_X_CUBE_AI_Process();
}I read the X, Y, and Z of the accelerometer sensor data.
Do you have any ideas on how I could handle this situation?
Thanks,
