2025-01-23 11:58 PM - last edited on 2025-01-24 12:25 AM by SofLit
MX_GPIO_Init();
MX_SPI2_Init();
MX_USART2_UART_Init();
MX_FATFS_Init();
/* USER CODE BEGIN 2 */
W25Qxxx_Init();
fres = f_mount(&fs,"0:",1);
if(fres == FR_OK)
{
v=9;
fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);
}
else
{
v=2;
}
trying to use spi flash using fatfs .
but occur hardfault handler when calling fopen . i am not sure whether it is from fopen or not.
Solved! Go to Solution.
2025-01-24 12:29 AM
Hello @NOVAL_______BOBY and welcome to the community,
Need to validate your read / write operation to the SPI Flash memory "W25Qxxx" before implementing FatFs on it.
2025-01-24 12:29 AM
Hello @NOVAL_______BOBY and welcome to the community,
Need to validate your read / write operation to the SPI Flash memory "W25Qxxx" before implementing FatFs on it.
2025-01-24 02:07 AM
tried read and write operations worked successfuly but when i try this again
fres = f_mkfs("0:", FM_FAT, 0, worK, sizeof(worK));
fres = f_mount(&fs,"0:",1);
if(fres == FR_OK) {
v=9;
fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);
}
else {
v=fres;
}
i got
HardFault_Handler() at stm32l0xx_it.c:85 0x80008b4
what should be reason any idea??
2025-01-24 03:44 AM - last edited on 2025-01-24 03:52 AM by Andrew Neil
Duplicate - merged.
tried read and write operations worked successfully but when i try this again
fres = f_mkfs("0:", FM_FAT, 0, worK, sizeof(worK));
fres = f_mount(&fs,"0:",1);
if(fres == FR_OK) {
v=9;
fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);
}
else {
v=fres;
}
i got
HardFault_Handler() at stm32l0xx_it.c:85 0x80008b4 Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap) HardFault_Handler() at stm32l0xx_it.c:85 0x80008d8 () at 0xfffffff9 HAL_SPI_TransmitReceive() at stm32l0xx_hal_spi.c:1,308 0x8003128 HAL_SPI_Receive() at stm32l0xx_hal_spi.c:979 0x8002ca4 W25Qxxx_ReadPage() at w25q32.c:800 0x80010a8 W25Qxxx_ReadSector() at w25q32.c:839 0x8001160 W25Qxxx_diskio_read() at w25q32.c:974 0x8001250 disk_read() at diskio.c:122 0x800406c move_window() at ff.c:925 0x80045fe check_fs() at ff.c:2,971 0x80053f8 <...more frames...>
what should be reason any idea??
Post edited to format code - please see this for posting source code, and this for other "formatted" text.
2025-01-24 03:49 AM
It's hard to tell:
See "How to debug a HardFault on an Arm Cortex®-M STM32"