SD Card Read and Write Concept

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SD Card Read and Write Concept

709 次查看
Dileep1441
Contributor I

Hi,

I want read and write the SD Card in S32K144 MCU, please share the example code(until now i used can_pal_S32k144, adc_pal_S32k144) so please share the similar example code for SD Card read and write.

 

Software:S32 Design Studio for ARM Version: 2018.R1

MCU:S32K144

 

Thanks in Advance.

0 项奖励
回复
3 回复数

687 次查看
Dileep1441
Contributor I

Hello,

Can anyone give some response to my previous post with an SDCARD Read and Write Example code over the SPI in S32K144EVB.

0 项奖励
回复

639 次查看
yu1
Contributor I

 

void WriteSignleBlock(void) // 写单块操作
{
LPSPI_DRV_MasterTransfer(SEND, CMD24, NULL, 6);//发送CMD24
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));//等待spi空闲
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);// 发送两个时钟读取返回值
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, WSBF, NULL, 1); //发送写标志位
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
for(a=0;a<512;a++) //发送512个字节数据
{
LPSPI_DRV_MasterTransfer(SEND,&write_512byte[a], NULL, 1);//
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
}
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1); // 发送两个CRC校验码
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
for(i=0;i<6;i++)
{
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
}
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
}

void ReadSignleBlock(void) // 读单块操作
{
LPSPI_DRV_MasterTransfer(SEND, CMD17, NULL, 6);//发送CMD17 读单块操作
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);//发送两个时钟读取返回值
do{
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
}while(slaveDataReceive!=0xfe); //读取读标志位

for(a=0;a<512;a++) //读512个字节数据
{
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
read_512byte[a] = slaveDataReceive;
}
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);//两个CRC校验码
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
LPSPI_DRV_MasterTransfer(SEND, CMD12, NULL, 6);//发送CMD12 停止读操作
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
for(i=0;i<6;i++)
{
LPSPI_DRV_MasterTransfer(SEND, &slaveDataSend, &slaveDataReceive, 1);
while(LPSPI_DRV_MasterGetTransferStatus(SEND,&STATUS));
}
}

0 项奖励
回复

630 次查看
Dileep1441
Contributor I

Hi @yu1, or anyone,

Thanks for the reply

 

Can you please share the File Creation,Write and Read functionalities code in SDCARD with S32KA144

0 项奖励
回复