I am trying to compile sc_sdcard for startKIT.
I am using the interface 0 defined in the library for SPI signals, that is
Code: Select all
static SDHostInterface SDif[] = {XS1_CLKBLK_1, XS1_CLKBLK_2, XS1_PORT_1O, XS1_PORT_1M, XS1_PORT_1N, XS1_PORT_1P, 0, 0}; // resources used for interface #0
When I run the application, It just hangs, I have place printf functions to get into the failure, what I found is kind of disconcerting, it happens that the function disk_initialize; produce some problem at execution time, inside the function there is a call to rcvr_mmc, which generates the initial clock for initialization, the function code is
Code: Select all
void rcvr_mmc (BYTE drv,
BYTE buff[], /* Pointer to read buffer */
UINT bc /* Number of bytes to receive */
)
{
BYTE d;
partout(SDif[drv].mosi, 8, 0xFF); // mosi high
clearbuf(SDif[drv].miso);
for(int i = 0; i < bc; i++)
{
partout(SDif[drv].sclk, 16, CLK_PATTERN); // load 8 clock
d = partin(SDif[drv].miso, 8);
buff[i] = bitrev(d) >> 24;
}
}
The execution hangs forever when it enter this function, I think the problem resides in this function, if I place a printf at the beginning, I see that it re enter by far more than 10 times, but the call is a finite for loop, as defined in disk_initialize; as
Code: Select all
for (n = 10; n; n--) rcvr_mmc(drv, buf, 1); /* 80 dummy clocks */
I am pretty new to XMOS, I know the sc_sdcard was not code for startKIT analog IC, but I guess it should be easily ported.
I will appreciate your comments,
Best,