본문 바로가기

[MCU]/CANTUS

[CANTUS EVM] SD Card 테스트

[CANTUS EVM] SD Card 테스트



CANTUS 는 SDIO를 지원하므로 SD Card를 고속으로 접근할 수 있다. [CANTUS EVN]보드 뒷면에는 T-Flash를 연결할 수 있도록 해서 SDIO를 테스트 해 볼 수 있다.

[CANTUS EVM] SD Card 회로도





CANTUS개발환경의에는 SD Card제어를위한 라이버러리를 제공기 때문에 쉽게 테스트 가능하다.
#include "system.h"
#include "serial.h"

unsigned int scan_files (char* path)
{
 unsigned int file_cnt = 0;
    FRESULT res;
    FILINFO fno;
    DIR dir;
    int i;
    char *fn;
 
#if _USE_LFN
    static char lfn[_MAX_LFN * (_DF1S ? 2 : 1) + 1];
    fno.lfname = lfn;
    fno.lfsize = sizeof(lfn);
#endif

 DebugPrint("Open..");
    res = f_opendir(&dir, path);
 
    if (res == FR_OK) {
        i = strlen(path);
  DebugPrint("OK.");
        for (;;) {
            res = f_readdir(&dir, &fno);
            if (res != FR_OK || fno.fname[0] == 0) break;
#if _USE_LFN
            fn = *fno.lfname ? fno.lfname : fno.fname;
#else
            fn = fno.fname;
#endif
            if (fno.fattrib & AM_DIR) {
                DebugPrint("[D]%s\r\n",fn);
            } else {
                DebugPrint("%s/%s : \t\t %dbyte\r\n", path, fn,fno.fsize);
            }
        }
    }
 else{
  DebugPrint("path(%s) not found:Error(%d)\r\n",path,res);
  
 }
 
    return file_cnt;
}

int main()
{
 FATFS fs;
 int file_cnt;
 
 SystemInit();
 
 DebugInit(BAUD_115200);
 DebugPrint("CANTUS SD Card Test3\r\n");
  
 DebugPrint("System Clock(%dMhz)\r\n",GetAHBclock()/1000000); 

 Led1Init();
 Led1On();

 DebugPrint("Mount..."); 
 if(f_mount(DRIVE_SDCARD,&fs) != FR_OK)
 {
  DebugPrint("Error");
  while(1);
 }
 else DebugPrint("OK\r\n");
 
 DebugPrint("File Search:\r\n");
 
 file_cnt = scan_files("1:");
 DebugPrint("file count:%d\r\n", file_cnt);
 while(1);

 return 1;
}




CANTUS SD Card테스트 결과
SD Memory Card
Identification Mode Start
the mandatory maximum operating frequency of SD Memory Card : 25Mhz
SD Memory Size : 485Mbyte ,Blocksize:512byte
SD CARD Initialize Completed
SDCard operating frequency:18800640
OK.
File Search:
1:/a_3.bmp :    192054byte
1:/a_12.bmp :    192054byte
1:/img1.bmp :    192054byte
1:/img2.bmp :    192054byte
file count : 4
반응형