Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
I am using an STM32 Nucleo-F446RE with the Ethernet Wiznet W5500 via SPI. The SPI is configured as Master, CPOL = Low, CPHA = 1st Edge, 8-bit data, BaudRatePrescaler = 16. I see correct SPI waveforms on the oscilloscope, but I encounter a hard fault when debugging.
I have disabled other SPI modules to avoid conflicts. Here is the relevant initialization code:
// SPI and W5500 Initialization
void MX_SPI1_Init(void)
{
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
}
void W5500_Init(void)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); // Reset W5500
HAL_Delay(1);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
HAL_Delay(1);
uint8_t reg = 0x01; uint8_t value = 0xF0;
HAL_SPI_Transmit(&hspi1, ®, 1, HAL_MAX_DELAY);
HAL_SPI_Transmit(&hspi1, &value, 1, HAL_MAX_DELAY);
}
Fault registers when the crash occurs:
– CFSR: `0x00000002` (Data bus error)
– HFSR: `0x40000000` (Forced hard fault)
– BFAR: `0x20001000` (Faulty memory access)
I am using STM32CubeIDE. Below is my HardFault handler:
void HardFault_Handler(void)
{
while (1) {}
}
Could someone please help me resolve this issue? ππ½.
CONTRIBUTE TO THIS THREAD