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.

TMS570LS3137: 使用SPI操作HDK开发版上的micro SD卡

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

你好

我试着使用TMS570LS3137HDK开发版测试SPI与microSD卡通信,但是我无法初始化SD卡,我试着更换了32g和16g的SD卡,我也没有找到相关代码示例。

接收的数据一直是0xFF,我不知道是哪里出了问题。

下面是代码和配置

谢谢

int main(void)
{
/* USER CODE BEGIN (3) */
    gioInit();
    sciInit();
    spiInit();

    spiDAT1_t spiDat1;
    spiDat1.CS_HOLD = FALSE;
    spiDat1.WDEL = TRUE;
    spiDat1.DFSEL = SPI_FMT_0;
    spiDat1.CSNR = SPI_PIN_CS0;

    // 发送80个信号
    for (int i = 0; i < 80; i++) {
        spiTransmitData(spiREG2, &spiDat1, 1, 0xFF);
    }

    uint16_t tData[6] = {0x40, 0x00, 0x00, 0x00, 0x00, 0x95};
    uint16_t rData[1] = {0};

    uint32 tRes = spiTransmitAndReceiveData(spiREG2, &spiDat1, 6, tData, NULL);

    while (1) {
        uint32 rRes = spiTransmitAndReceiveData(spiREG2, &spiDat1, 1, NULL, rData);
        if (rData[0] == 0x01) {
            while (1) {
                printf("ok");
            }
        }
    }
/* USER CODE END */

    return 0;
}

我再发送CMD0后没有收到R1信号,这是我第一次试着连接SD卡。

下面是我的halcogen截图