谢谢您的回复,SOSCSEL是off对不起,我是编程PIC的初学者,并且我正在尝试使用MLA库来写入microSD卡,所以我真的不确定您所说的主发送是什么意思。通过代码,我发现它似乎正在使用SPI1_Exchange函数向SD卡发送数据。在FILEIO_SD_MediaInitialize函数中多次调用它。我打开SFR窗口,转到SPI1BUFL(030C),看到值有时会发生变化,尽管我对确切的需要被发送感到困惑,这主要是因为函数需要数据的指针,并且我还没有弄清楚如何查看数据。初始化有一个do-while循环等待看到它对数据发送的响应是0x01。注意,put.还调用SPI1_Exchange来发送dataFILEIO_SD_MediaInitialize后面有一个if语句,它没有进入(mediaInformation->errorCode!= MealAuthNOnError){Frime= FieloOyErrOrthInITyOrror;},这意味着PPS是正确设置的,对吗?我在DRIVEMUNT函数中的某个地方仍然有错误,但是它不是来自PPS设置,对吗?
以上来自于百度翻译
以下为原文
Thanks for the response, SOSCSEL is off
Sorry, I am a beginner at programming PIC, and I am trying to use the MLA library to write to microSD card, so I'm not really sure what you mean by master send. Stepping through the code, I see that it seems to be sending data to SD card usingthe SPI1_Exchange function
void SPI1_Exchange( void *pTransmitData, void *pReceiveData )
{
uint8_t dummyRead = 0;
uint8_t dummyWrite = spi1DummyData;
if(pTransmitData == NULL)
{
pTransmitData = &dummyWrite;
}
if(pReceiveData == NULL)
{
pReceiveData = &dummyRead;
}
while( SPI1STATLbits.SPITBF == true )
{ }
// ----------------
// sending data
// ----------------
SPI1BUFL = *((uint8_t*)pTransmitData);
while ( SPI1STATLbits.SPIRBE == true)
{ }
// ----------------
// extracting data
// ----------------
*((uint8_t*)pReceiveData) = (uint8_t)(SPI1BUFL);
}
This is called many times in the FILEIO_SD_MediaInitialize function. I opened the SFR window and go to SPI1BUFL(030C) and I see that the value will sometimes change, though I am really confused on exactly want is being sent, mostly because the function takes pointers for the data, and I haven't figured out how to look at the data.
I did notice that in FILEIO_SD_MediaInitialize there's a do-while loop waiting to see it the response to the data sent is 0x01. Note, put slow also calls SPI1_Exchange to send data
do
{
//Toggle chip select, to make media abandon whatever it may have been doing
//before. This ensures the CMD0 is sent freshly after CS is asserted low,
//minimizing risk of SPI clock pulse master/slave synchronization problems,
//due to possible application noise on the SCK line.
(*config->csFunc)(1);
FILEIO_SD_SPI_Put_Slow(config->index, 0xFF); //Send some "extraneous" clock pulses. If a previous
//command was terminated before it completed normally,
//the card might not have received the required clocking
//following the transfer.
(*config->csFunc)(0);
timeout--;
//Send CMD0 to software reset the device
response = FILEIO_SD_SendMediaCmd_Slow(config, FILEIO_SD_GO_IDLE_STATE, 0x0);
}while((response.r1._byte != 0x01) && (timeout != 0));
There is an if statement after FILEIO_SD_MediaInitialize, which it does not go into
if (mediaInformation->errorCode != MEDIA_NO_ERROR)
{
error = FILEIO_ERROR_INIT_ERROR;
}
So this means that the PPS is being set up correctly right? I am still getting an error somewhere in the DriveMount function, but its not from the PPS setup, correct?
谢谢您的回复,SOSCSEL是off对不起,我是编程PIC的初学者,并且我正在尝试使用MLA库来写入microSD卡,所以我真的不确定您所说的主发送是什么意思。通过代码,我发现它似乎正在使用SPI1_Exchange函数向SD卡发送数据。在FILEIO_SD_MediaInitialize函数中多次调用它。我打开SFR窗口,转到SPI1BUFL(030C),看到值有时会发生变化,尽管我对确切的需要被发送感到困惑,这主要是因为函数需要数据的指针,并且我还没有弄清楚如何查看数据。初始化有一个do-while循环等待看到它对数据发送的响应是0x01。注意,put.还调用SPI1_Exchange来发送dataFILEIO_SD_MediaInitialize后面有一个if语句,它没有进入(mediaInformation->errorCode!= MealAuthNOnError){Frime= FieloOyErrOrthInITyOrror;},这意味着PPS是正确设置的,对吗?我在DRIVEMUNT函数中的某个地方仍然有错误,但是它不是来自PPS设置,对吗?
以上来自于百度翻译
以下为原文
Thanks for the response, SOSCSEL is off
Sorry, I am a beginner at programming PIC, and I am trying to use the MLA library to write to microSD card, so I'm not really sure what you mean by master send. Stepping through the code, I see that it seems to be sending data to SD card usingthe SPI1_Exchange function
void SPI1_Exchange( void *pTransmitData, void *pReceiveData )
{
uint8_t dummyRead = 0;
uint8_t dummyWrite = spi1DummyData;
if(pTransmitData == NULL)
{
pTransmitData = &dummyWrite;
}
if(pReceiveData == NULL)
{
pReceiveData = &dummyRead;
}
while( SPI1STATLbits.SPITBF == true )
{ }
// ----------------
// sending data
// ----------------
SPI1BUFL = *((uint8_t*)pTransmitData);
while ( SPI1STATLbits.SPIRBE == true)
{ }
// ----------------
// extracting data
// ----------------
*((uint8_t*)pReceiveData) = (uint8_t)(SPI1BUFL);
}
This is called many times in the FILEIO_SD_MediaInitialize function. I opened the SFR window and go to SPI1BUFL(030C) and I see that the value will sometimes change, though I am really confused on exactly want is being sent, mostly because the function takes pointers for the data, and I haven't figured out how to look at the data.
I did notice that in FILEIO_SD_MediaInitialize there's a do-while loop waiting to see it the response to the data sent is 0x01. Note, put slow also calls SPI1_Exchange to send data
do
{
//Toggle chip select, to make media abandon whatever it may have been doing
//before. This ensures the CMD0 is sent freshly after CS is asserted low,
//minimizing risk of SPI clock pulse master/slave synchronization problems,
//due to possible application noise on the SCK line.
(*config->csFunc)(1);
FILEIO_SD_SPI_Put_Slow(config->index, 0xFF); //Send some "extraneous" clock pulses. If a previous
//command was terminated before it completed normally,
//the card might not have received the required clocking
//following the transfer.
(*config->csFunc)(0);
timeout--;
//Send CMD0 to software reset the device
response = FILEIO_SD_SendMediaCmd_Slow(config, FILEIO_SD_GO_IDLE_STATE, 0x0);
}while((response.r1._byte != 0x01) && (timeout != 0));
There is an if statement after FILEIO_SD_MediaInitialize, which it does not go into
if (mediaInformation->errorCode != MEDIA_NO_ERROR)
{
error = FILEIO_ERROR_INIT_ERROR;
}
So this means that the PPS is being set up correctly right? I am still getting an error somewhere in the DriveMount function, but its not from the PPS setup, correct?
举报