Board logo

标题: 关于MC13192用SPI读取接收到数据程序中的问题?RAMDrvReadRx() [打印本页]

作者: adam1982    时间: 2007-7-25 21:49     标题: 关于MC13192用SPI读取接收到数据程序中的问题?RAMDrvReadRx()

在MCU读取13192接收到的数据主要用到在drivers.c的RAMDrvReadRx()函数,我对这函数中一段代码不是很理解还请指导下代码如下)这代码中有四个Dummy write,目的应该是为了防止读取四个GARBAGE吧(MSB,LSB,LSB,LSB),我问题为什么要这样来假写数据到寄存器,为什么要四次DUMMYWRITE,为什么针对的是一个MSB.,三个LSB,(我的理解至少也应该是MSB,LSB,MSB,LSB两个字)?还请指导下,谢谢
SPIClearRecieveDataReg(); /*
* Clear receive data register.
* SPI entirely ready for read or write
*/
SPISendChar(u8TempValue); /*
* Dummy write. Receive register of SPI will
* contain MSB garbage for first read
//#define SPIWaitTransferDone() while (!(SPI1S_SPRF)); */
SPIWaitTransferDone(); /* For this bit to be set, SPTED MUST be set.*/
SPIClearRecieveDataReg(); /*
* Clear receive data register.
* SPI entirely ready for read or write
*/
SPISendChar(u8TempValue); /*
* Dummy write. Receive register of SPI will
* contain LSB garbage for first read
*/
SPIWaitTransferDone(); /* For this bit to be set, SPTED MUST be set.*/
SPIClearRecieveDataReg(); /*
* Clear receive data register.
* SPI entirely ready for read or write
*/
/* Byte codes */
SPISendChar(u8TempValue); /*
* [U]Dummy write[/U]. Receive register of SPI will
* contain LSB garbage for first read
*/
SPIWaitTransferDone(); /* For this bit to be set, SPTED MUST be set.*/
u8TempValue = SPIRead(); /* Read first code byte */
SPISendChar(u8TempValue); /*
* Dummy write. Receive register of SPI will
* contain LSB garbage for first read
*/
SPIWaitTransferDone(); /* For this bit to be set, SPTED MUST be set.*/
u8TempValue = SPIRead(); /* Read second code byte */
作者: adam1982    时间: 2007-7-26 16:09

版主能指点下吗?
作者: nofaiture2004    时间: 2010-4-24 08:08

顶一下!!

我也对这东西有疑问!!




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0