SD card access freeze on LPC1788 with Chan FatFS

While using Chan FatFS library, I encountered frequent system freezes on my MOD-LCD4.3 board when performing read or write operations on the SD card. The board, which is based on the LPC1788 Cortex M-3, features an SD card connector.

The system is running FreeRTOS and utilizes the MCI interface from NXP (lpc177x_8x_mci.c) in DMA mode for SD card access with a custom low-level driver which implements disk_status(), disk_initialize(), disk_read(), disk_write(), and disk_ioctl() operations.

ChaN’s FatFs interface

The freeze was not systematic, and each time it occurred, the system was stuck at MCI_GetDataXferEndState() during disk_read() and disk_write() operations. Furthermore, its frequency tended to increase with the system workload.

To fix the issue:

#define DATA_TIMER_VALUE 0x10000

to

#define DATA_TIMER_VALUE 0xF0000
  • Suspend the scheduler keeping interrupts; if you are using FreeRTOS:
vTaskSuspendAll();
SD_card_access_task();
xTaskResumeAll();

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *