Other Parts Discussed in Thread: SYSBIOS, TM4C123FH6PM, TM4C123GH6PM, EK-TM4C123GXL
主题中讨论的其他器件:SYSBIOS、 TM4C123GH6PM、 EK-TM4C123GXL、 DK-TM4C129X
大家好、
我正在尝试端口 FatSDRaw 示例以使用 USB 大容量存储设备。
没有直接使用 fatfs 的 USB 示例、因此我首先将 USB 示例从129移植到123。
我可以读取 USB 记忆棒并打开文件、并使用 fatfs 调用读取其内容。
这让我相信我所面临的问题与 USB 无关。
但是、当我尝试创建一个新文件时、我会得到一个系统中止。
为了测试我是否做了错误、我用了一个针对129的 FatSDRaw 示例并将 SPI 部件更改为 USBMscFat、我可以创建新文件而不会出现任何问题。
我也在我的 cfg 文件中启用了 FatFS。
我使用调试器将中止跟踪到以下函数调用。
ff.c -> f_open ->第2509行"dw = get_FATTIME ();"
get_FATTIME();是调用 get_fattime()的定义;
diskio.c get_fattime 调用 ti_mw_fatfs_getFatTime();
在由 XDC 工具创建的 pem4f.c 文件中实现。
该函数的内容如下:
Int32 ti_mw_fatfs_getFatTime(Void)
{
time_t seconds;
UInt32 fatTime;
struct tm *pTime;
seconds = time(NULL);
pTime = localtime(&seconds);
/*
* localtime() sets pTime->tm_year to number of years
* since 1900, so subtract 80 from tm_year to get FAT time
* offset from 1980.
*/
fatTime = ((UInt32)(pTime->tm_year - 80) << 25) |
((UInt32)(pTime->tm_mon) << 21) |
((UInt32)(pTime->tm_mday) << 16) |
((UInt32)(pTime->tm_hour) << 11) |
((UInt32)(pTime->tm_min) << 5) |
((UInt32)(pTime->tm_sec) >> 1);
return ((Int32)fatTime);
}
在 seconds = time (NULL);行上调用 time 函数。
time_t ATTRIBUTE time(time_t *tout)
{
UInt32 t;
/* Seconds_get() returns number of seconds since Jan 1, 1970 00:00:00 GMT. */
t = ti_sysbios_hal_Seconds_get();
#if defined(__ti__)
/*
* TI time() function returns seconds since 1900, so add the number
* of seconds from 1900 to 1970 (2208988800).
*/
t += 2208988800;
#endif
if (tout) {
*tout = t;
}
return (t);
}
第 t 行= ti_sysbios_hal_dseconds_get ();
seconds_get();seconds.c 文件中的函数被调用。
UInt32 Seconds_get(Void)
{
UInt32 curSeconds;
UInt32 seconds = 0;
curSeconds = HWREG(HIB_RTCC);
seconds = curSeconds - Seconds_module->refSeconds +
Seconds_module->setSeconds;
return (seconds);
}
这是我获取中止的位置。
它访问休眠 RTC 寄存器、因此我的直觉是 RTC 未启用、并会发生硬故障。
是否有人曾遇到过类似的问题、他们可以帮助我?