Skip to content

HardFault Handler when using CANOpenNodeSTM32 with freeRTOS #86

@Mihnea29

Description

@Mihnea29

Hello. I have tried using CANOpen with freertos. I have created a task for the app process and I am calling the app interrupt with a semaphore. The app goes inside the initialisation function but the hard fault handler is called. I think the issue is that the heap memory used parameter is 0 and I can't figure out why.

void canopen_task(void argument)
{
/
USER CODE BEGIN canopen_task /
CANopenNodeSTM32 canOpenNodeSTM32;
canOpenNodeSTM32.timerHandle = &htim14;
canOpenNodeSTM32.CANHandle = &hcan1;
canOpenNodeSTM32.HWInitFunction = MX_CAN1_Init;
canOpenNodeSTM32.desiredNodeID = 1;
canOpenNodeSTM32.baudrate = 100;
canopen_app_init(&canOpenNodeSTM32);
/
Infinite loop */
for(;;)
{
if (osSemaphoreAcquire(canSemHandle, 10) == osOK) {
canopen_app_interrupt();
}
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_5, !canOpenNodeSTM32.outStatusLEDGreen);
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_13, !canOpenNodeSTM32.outStatusLEDRed);
canopen_app_process();

osDelay(1);

}
/* USER CODE END canopen_task */
}

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef htim)
{
/
USER CODE BEGIN Callback 0 */

/* USER CODE END Callback 0 /
if (htim->Instance == TIM6)
{
HAL_IncTick();
}
/
USER CODE BEGIN Callback 1 /
if (htim == canopenNodeSTM32->timerHandle) {
//canopen_app_interrupt();
osSemaphoreRelease(canSemHandle);
}
/
USER CODE END Callback 1 */
}

osThreadId_t CanopenTaskHandle;
const osThreadAttr_t CanopenTask_attributes = {
.name = "CanopenTask",
.stack_size = 2048 * 4,
.priority = (osPriority_t) osPriorityHigh,
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions