Question
Hardfault error in SPI slave - polling mode
Hi, I am using cubemx to configure a stm32f411ve board as slave in receive only, polling mode and sofware NSS, in the code generated I have only added a few lines of code, only which I consider neccesary
**the master sends 12 bytes
outside main function:
uint8_t rxbuffer[12];
void Timeout_Error_Handler()
{
while(1){
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_13); //led orange
HAL_Delay(500);
}
}
void Error_Handler2()
{
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET); //led red
}
inside main function:
// I have commented the while (1) because for my test the master sends data just one time
//while (1)
{
/* USER CODE END WHILE */
MX_USB_HOST_Process();
/* USER CODE BEGIN 3 */
switch (HAL_SPI_Receive(&hspi5,rxbuffer,12,5000))
{
case HAL_OK:
/* Turn LED6 on: Transfer in reception process is correct */
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_SET); //led blue
break;
case HAL_TIMEOUT:
Timeout_Error_Handler();
break;
case HAL_ERROR:
Error_Handler2();
break;
default:
break;
}the issue is that in debug mode I can see after the HAL_SPI_Receive function the program goes to a hardfault handler function.
do you know what could be the problem?
thanks
