自己做的pcb板。用stc12c5a60s2 I/O口推挽输出。采用电阻分压。
SD卡套上用电表测量3.3v电平正确。
但是读出的数据总是0xff
unsigned char SD_spi_read(void)
{
UART_Send_Str("b");//测试用
SD_SO = 1;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat7 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat6 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat5 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat4 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat3 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat2 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat1 = SD_SO;
SD_SCL = 1;
if (is_init) delay(DELAY_TIME);
SD_SCL = 0;
if (is_init) delay(DELAY_TIME);
_dat0 = SD_SO;
UART_Send_Byte(_dat);//通过串口查看总是0xFF
return _dat;
}
|