This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/MSP430FR2355:写入 MSP430fr2355上的 SD 卡时出现问题

Guru**** 3005300 points

Other Parts Discussed in Thread: MSP430FR2355

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/916881/ccs-msp430fr2355-problems-with-writing-to-a-sd-card-on-a-msp430fr2355

器件型号:MSP430FR2355

工具/软件:Code Composer Studio

大家好、

我尝试使用 msp430fr2355将数据记录到 SD 卡。 我使用了几个示例的组合、因为我的微控制器没有任何示例。 我现在使用的库是用于制作文件的 FATFS、HAL_SDCard 使用 SPI。 以下代码是我的主要代码:

#include
#include "FatFs/ff.h"
#include "FatFs/diskio.h"

#include
#include "driverlib.h"
#include "Board.h"
#include

int fat_init();
int SDCard_init();

FIL 文件;/*打开的文件对象*/
FATFS Fatfs;/*文件系统对象*/
FRESULT 错误代码;//错误代码对象*/
FRESULT 分辨率;/*结果对象*/
uint8_t bytesRead;/*字节读取对象*/
uint8_t 读取;/*读取字节对象*/

dir dir;//目录对象*/
方向2;

FATFS test_for_new;//检查是否可以写入新文件
fil test_file;

int 结果= 1;


int main (空)
{
//initCLK();
WDTCTL = WDTPW+WDTHOLD;

_enable_interrupt ();

f_mount (0、0);

//volatile int i;
sdcard_init();
fat_init();

//f_mount (0、0);

while (1)
{
unsigned int bytesWritten;
f_write (&file、"abcdefg \r\n"、32、bytesWritten);
//for (i=50000;i>0;i--);
}
}

int fat_init()
{
错误代码=-1;

while (errCode!= FR_OK){//go、直到 f_open 返回 FR_OK (函数成功)
错误代码= f_mount (0、&fatfs);//安装驱动器编号0
errCode = f_opendir (&dir、"/");//root 目录

错误代码= f_open (&file、"test.txt"、fa_create_always | fa_write);
if (错误代码!= FR_OK)
Result = 0;//用作调试标志
}
返回0;
}

当我运行脚本时、它似乎卡在 FATinit。 它可能位于 SPI 中、因为我无法使用逻辑分析仪看到任何内容。 但不止此、我才知道。 是否有人知道问题可能出在哪里? 我在这一点上看到的所有示例都不支持我的微控制器、也不深入代码以使其正常工作。