Ti工程师您好!
现在我遇到一个问题,SPI用片选1连接外设AD,但是现在SPI没有输出信号,clock也没有输出信号。
程序是我在例程里修改的,例程里是用SPI往EEPROM里写数据,把例程用ezdsp开发板仿真,也是没有数据的。
不知道哪里出问题了。我下载了好几个版本的例程都不行。
#include <stdio.h> #include <csl_spi.h> #include <cslr_spi.h> #include <csl_sysctrl.h> #include <csl_general.h> #include <spirom.h> #define CSL_TEST_FAILED (1) #define CSL_TEST_PASSED (0) #define CSL_SPI_BUF_LEN (64) #define SPI_CLK_DIV (10000) #define SPI_FRAME_LENGTH (1) Uint16 spiWriteBuff[CSL_SPI_BUF_LEN]; Uint16 spiReadBuff[CSL_SPI_BUF_LEN]; Uint16 byteBuf[1]; Uint16 cmdBuffer[3] = {0, 0, 0}; long delay_i; extern void spirom_write( Uint32 src, Uint16 dst, Uint32 length ); CSL_SpiHandle hSpi; Int16 spi_sample(void) { Int16 status = CSL_TEST_FAILED; Int16 result; SPI_Config hwConfig; Uint16 looper; /*Uint16 value = 0; Uint16 pageNo = 0x0000; Uint16 pollStatus; Uint16 delay; Uint16 fnCnt;*/ result = SPI_init(); if(CSL_SOK != result) { status = CSL_TEST_FAILED; return (status); } else { printf ("SPI Instance Intialize successfully\n"); } hSpi = SPI_open(SPI_CS_NUM_1, SPI_POLLING_MODE); if(NULL == hSpi) { return (CSL_TEST_FAILED); } else { printf ("SPI Instance Opened successfully\n"); } /** Set the hardware configuration */ hwConfig.*** = SPI_CLK_DIV; hwConfig.wLen = SPI_WORD_LENGTH_8; hwConfig.frLen = SPI_FRAME_LENGTH; hwConfig.wcEnable = SPI_WORD_IRQ_ENABLE; hwConfig.fcEnable = SPI_FRAME_IRQ_DISABLE; hwConfig.csNum = SPI_CS_NUM_1; hwConfig.dataDelay = SPI_DATA_DLY_1; hwConfig.csPol = SPI_CSP_ACTIVE_LOW; hwConfig.clkPol = SPI_CLKP_LOW_AT_IDLE; hwConfig.clkPh = SPI_CLK_PH_FALL_EDGE; result = SPI_config(hSpi, &hwConfig); if(CSL_SOK != result) { return (CSL_TEST_FAILED); } else { printf ("SPI Instance Configured successfully\n"); } byteBuf[0] = 0xABCD; for(looper = 0; looper < 64; ) { spiWriteBuff[looper] = 0x0011; spiWriteBuff[(looper + 1)] = 0x00AB; spiReadBuff[looper] = 0x0000; spiReadBuff[(looper + 1)] = 0x00CD; looper += 2; } return (status); } void main(void) { Int16 status; pll_sample(); //时钟初始化 status = spi_sample(); while(1) { delay_i = 50000; while(delay_i--); SPI_dataTransaction(hSpi ,spiWriteBuff, CSL_SPI_BUF_LEN, SPI_WRITE); } }