大家好,我最近在利用tms570ls0914通过spi来对外部eepromi进行访问读写,遇到了几个问题,想请教一下大家
我在用HAL生成spi.c之后在写完简单的读写程序后一直不能发送和读写数据不管是用mibspi还是spi都不能成功发送
下面是我的程序
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "sys_mpu.h"
#include "sci.h"
#include "spi.h"
#include "gio.h"
#include "rti.h"
#include "adc.h"
#include "mibspi.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
uint16 WR_WR[3]={0x0006,0x0211,0x11FF};
uint16 WR_RD[3]={};
uint16 RD_WR[2]={0X0311,0X1100};
uint16 RD_RD[2]={};
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
int i;
mibspiInit();
mibspiEnableLoopback(mibspiREG1,Digital_Lbk);
mibspiEnableGroupNotification(mibspiREG1,0,0);
mibspiEnableGroupNotification(mibspiREG1,1,0);
mibspiSetData(mibspiREG1,0,WR_WR);
for(i=0;i<10000;i++);
mibspiSetData(mibspiREG1,1,RD_WR);
for(i=0;i<10000;i++);
while(1)
{
mibspiTransfer(mibspiREG1,0);
for(i=0;i<10000;i++);
mibspiTransfer(mibspiREG1,1);
for(i=0;i<10000;i++);
if( mibspiIsTransferComplete (mibspiREG1,0)==1)
{mibspiGetData(mibspiREG1,0,WR_RD);}
for(i=0;i<10000;i++);
if( mibspiIsTransferComplete (mibspiREG1,1)==1)
{mibspiGetData(mibspiREG1,1,RD_RD);}
for(i=0;i<10000;i++);}
}
然后我也用spi写了,下面是spi的程序
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "spi.h"
#include "gio.h"
#include "sci.h"
#include "adc.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
uint16 WR_WR[3]={0x0006,0x0211,0x11FF};
uint16 WR_RD[3]={};
uint16 RD_WR[2]={0X0311,0X1100};
uint16 RD_RD[2]={};
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
spiInit();
int i;
spiDAT1_t dataconfig1_t;
spiTransmitAndReceiveData(spiREG2, &dataconfig1_t, 16, WR_WR, WR_RD);
for(i=0;i<10000;i++);
spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, RD_WR, RD_RD);
for(i=0;i<10000;i++);
}
两种方式都不对,想请教一下大家是不是我哪里写错了
Susan Yang:
很抱歉,目前手头没有板子供调试,所以对于您的问题很难回答
请您参考一下下面的链接
www.element14.com/…/talk-spi-to-eeprom-with-hercules-launchpad-hero
给出了相关的电路设计和源码
希望您能借鉴一下,谢谢
另外您也可以在E2E英文论坛发帖,以获取国外工程师的支持