-1

:)

First excuse my bad english. I hope you will understand my writing.

My aim is to build a high precission (24 bit) datalogger for a student project, which stores the data to SD-Card. I use the Arduino Due (ATSAM3X8E) and additional a selfmade shield with a SD-Card Connector.

Further I use Atmel Studio 6.2 and the ASF libraries "SD/MMC stack on SPI interface" and "FatFS file system".

It is allready possible to just write and read with the sd/mmc module by spi but without file system. So the hardware works correctly.

I suppose that my fault can be localized in the FatFS module.

In main.c I call the following functions:

  • sd_mmc_init();

  • sd_mmc_check(SD_SLOT); //until this the program works and I can read and write valid values with the terminal window

  • f_mount(LUN_ID_SD_MMC_0_MEM, &fs);

//it returns FR_OK but nevertheless may here is the first little fault, cause I'm not sure wether I have chosen the correct LUN.

  • f_open(&file_object,(char const *)test_file_name, FA_CREATE_ALWAYS | FA_WRITE);

// here appears the error FR_DISK_ERR // when I follow the error to lower level I come to the functions: - chk_mounted(&path, &dj.fs, (BYTE)(mode & ~FA_READ)); - fmt = check_fs(fs, bsect = 0); - and then in the lowest level my disk_read function which is part of diskio.c (attached)

later it has to follow the functions f_puts and f_close(&file_object); but without f_open, they cannot work.

I have attached my diskio.c file where the disk_read file is allocated which causes the error.

I really hope someone can help me. Thank you for all answers and hints!!!

1 Answers1

2

I ran into exactly the same problem. The solution was to add the define: ACCESS_MEM_TO_RAM_ENABLED. I did this just above where it was being checked around line 257 in conf_access.h

#define ACCESS_MEM_TO_RAM_ENABLED
#ifdef ACCESS_MEM_TO_RAM_ENABLED
#define ACCESS_MEM_TO_RAM    true  //!< MEM <-> RAM interface.
#else
#define ACCESS_MEM_TO_RAM    false //!< MEM <-> RAM interface.
#endif

I stepped through the code to find the source of the FR_DISK_ERR and found that define required apparently by the disk_read function in diskio.c

Once I added that define I was able to open a file, write to it, and close it. Best of all I could actually take out the SD card afterward and the file was actually written!

Patrick S.
  • 31
  • 4
  • When actually implementing this in a project I think it's cleaner to add the define to either your board.h or in my case just directly into the project compiler defines. – Patrick S. Oct 18 '16 at 21:26