This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C5505,SPI 7 signal mode下,无clk信号

大家好,

        最近调试C5505的SPI模块,设计要求通过SPI的cs0-3控制AD、DA等slave device的数据传输。遇到了没有时钟和片选信号的问题(附注:PCGCR中,只有SYSCLKDIS、TMR0CG、UARTCG这几个位active。其它的都disable。然后复位之后,再打开SPICG)。

我的问题是:External Bus Selection Register (EBSR)设置PPMODE为

                                                     1、4 signals of the SPI module有时钟信号且只有cs0有片选信号。

                                                     2、7 signals of the SPI module无时钟信号,但cs0-3有片选信号。

请问:1、这个问题该怎么解决,如何使7 signals of the SPI module下既有时钟信号又有片选信号?

            2、cs0-3是如何实现slave device的选择,其具体控制逻辑是什么?

万分期待您的解答,先谢谢各位!!!

adc.rar
  • EVM测试程序里有SPI例程,

    http://support.spectrumdigital.com/boards/evm5505/revd/

    也可以参考C5515 EVM板的例程,看哪个例程更适合你。

    http://support.spectrumdigital.com/boards/evm5515/revb/

    CSn由SPICMD2[CSNUM]控制.

  • 谢谢,这个问题已经解决了,是我的硬件接线接错了。现在还有一个问题就是HWAFFT无法正常工作。现在社区里相关的帖子和方式都试过了,还是没有找到问题的根源。您能不能提供一个你们那边测试OK的例子代码给我。供我参考一下。

    谢谢了

  •  你好,

               我现在用的 C5505  SPI  也出现问题了,clock 没信号。能不能帮我看下代码,或者能不能把您的SPI配置代码让我学习一下,谢谢

    #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			(100)	
    #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.spiClkDiv	= 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();
        //spirom_init();
          
          
          
          
          while(1)
    {
    	delay_i = 5000000;
    	while(delay_i--); 
    	
        SPI_dataTransaction(hSpi ,spiWriteBuff, CSL_SPI_BUF_LEN, SPI_WRITE);
    	
    
    }	
          
         
    }