野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 25496|回复: 6

一直FATFS的时候CC936.C为什么有错误

[复制链接]
发表于 2014-3-25 11:38:36 | 显示全部楼层 |阅读模式
为什么会样呢? QQ截图20140325112616.png
下面有个错误是这样的 222225113806.png
回复

使用道具 举报

发表于 2014-3-25 11:40:41 | 显示全部楼层
需要把ffconf.c文件里的宏配置好,
codepage宏要选成936
  1. #define _CODE_PAGE  936
  2. /* The _CODE_PAGE specifies the OEM code page to be used on the target system.
  3. /  Incorrect setting of the code page can cause a file open failure.
  4. /
  5. /   932  - Japanese Shift-JIS (DBCS, OEM, Windows)
  6. /   936  - Simplified Chinese GBK (DBCS, OEM, Windows)
  7. /   949  - Korean (DBCS, OEM, Windows)
  8. /   950  - Traditional Chinese Big5 (DBCS, OEM, Windows)
  9. /   1250 - Central Europe (Windows)
  10. /   1251 - Cyrillic (Windows)
  11. /   1252 - Latin 1 (Windows)
  12. /   1253 - Greek (Windows)
  13. /   1254 - Turkish (Windows)
  14. /   1255 - Hebrew (Windows)
  15. /   1256 - Arabic (Windows)
  16. /   1257 - Baltic (Windows)
  17. /   1258 - Vietnam (OEM, Windows)
  18. /   437  - U.S. (OEM)
  19. /   720  - Arabic (OEM)
  20. /   737  - Greek (OEM)
  21. /   775  - Baltic (OEM)
  22. /   850  - Multilingual Latin 1 (OEM)
  23. /   858  - Multilingual Latin 1 + Euro (OEM)
  24. /   852  - Latin 2 (OEM)
  25. /   855  - Cyrillic (OEM)
  26. /   866  - Russian (OEM)
  27. /   857  - Turkish (OEM)
  28. /   862  - Hebrew (OEM)
  29. /   874  - Thai (OEM, Windows)
  30. /  1    - ASCII only (Valid for non LFN cfg.)
  31. */
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-25 11:42:53 | 显示全部楼层
#include "stm32f10x.h"
#include "delays.h"
#include "ledcfg.h"
#include "USERusart.h"
#include "nviccfg.h"
#include "sdiocfg.h"
#include "ff.h"

/* Private typedef -----------------------------------------------------------*/
typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;

/* Private define ------------------------------------------------------------*/
#define BLOCK_SIZE            512 /* Block Size in Bytes */

#define NUMBER_OF_BLOCKS      32  /* For Multi Blocks operation (Read/Write) */
#define MULTI_BUFFER_SIZE    (BLOCK_SIZE * NUMBER_OF_BLOCKS)

#define SD_OPERATION_ERASE          0
#define SD_OPERATION_BLOCK          1
#define SD_OPERATION_MULTI_BLOCK    2
#define SD_OPERATION_END            3

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
SD_Error Status = SD_OK;
uint8_t wrbuffer[]="stm32";

int res;  
int a;

FIL fsrc,fdst;
FATFS fs;
UINT br, bw;            // File R/W count
BYTE buffer[512];       // file copy buffer
BYTE textFileBuffer[] = "感谢您选用 野火STM32开发板 !^_^ \r\n";

int main(void)
{
  
        Usart1_Init(115200);
          NVIC_config();
          USART_ClearFlag(USART1,USART_FLAG_TC);
        USART1_printf(USART1, "SDIOProject\r\n");
        USART1_printf(USART1, "SDIOProject\r\n");

          f_mount(&fs,0,1);
    res = f_open(&fdst,"0:/Demo.TXT",FA_CREATE_NEW | FA_WRITE);
        if ( res == FR_OK )
         {
    /* 将缓冲区的数据写到文件中 */
                res = f_write(&fdst, textFileBuffer, sizeof(textFileBuffer), &bw);
          USART1_printf(USART1,"\r\n 文件创建成功 \n" );   
      /*关闭文件 */
                    f_close(&fdst);      
          }
   else if ( res == FR_EXIST )
         {
                USART1_printf(USART1, "\r\n 文件已经存在 \n" );
         }
         
        res = f_open(&fdst, "0:/Demo.TXT", FA_OPEN_EXISTING | FA_READ); /* 打开文件 */               
        br = 1;
        a = 0;       
  for (;;)
        {
                for ( a=0; a<512; a++ )                                   /* 清缓冲区 */
                        buffer[a]=0;
                         
          res = f_read( &fdst, buffer, sizeof(buffer), &br ); /* 将文件里面的内容读到缓冲区 */
                USART1_printf(USART1,"\r\n %s ", buffer);                                               
          if (res || br == 0) break;                          /* 错误或者到了文件尾 */                           
  }
        f_close(&fdst);          
  while (1)
  {}
}
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-25 11:44:49 | 显示全部楼层
红舒扬 发表于 2014-3-25 11:40
需要把ffconf.c文件里的宏配置好,
codepage宏要选成936

我改完了  还是这样
回复 支持 反对

使用道具 举报

发表于 2014-3-25 14:45:01 | 显示全部楼层
你ff.h的头文件路径都没有添加
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-25 14:47:21 | 显示全部楼层
许亮 发表于 2014-3-25 14:45
你ff.h的头文件路径都没有添加

在那里添加?官方下载的cc936.c中有#include "../ff.h"
回复 支持 反对

使用道具 举报

发表于 2014-3-25 20:24:56 | 显示全部楼层
Summer 发表于 2014-3-25 14:47
在那里添加?官方下载的cc936.c中有#include "../ff.h"

在工程选项的  c/c++ 里添加头文件路径
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-31 06:19 , Processed in 0.032616 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表