Hi,
I want to communicate C5535 (eZdsp evaluation kit) with SPI based ADC (TLC3544), the configuration made for this is as below:
1. SPI_Write (A000h)
2. SPI_Write (A304h)- Internal reference used, mode zero, conversion clock= SCLK/4
3. SPI_Write (3000h)
The DSP is supposed to read the digital value from the channel 3. But this is not happening. One more question is how we will get to know the conversion has been completed without INT. The configuration is made as per the datasheet. The code is attached. Chip Select 2 is being used.
#include "csl_spi.h"
#include "csl_general.h"
#include <stdio.h>
#define CSL_TEST_FAILED (1)
#define CSL_TEST_PASSED (0)
#define CSL_SPI_BUF_LEN (1)
#define SPI_CLK_DIV (100) - SPI CLOCK is 1MHz
#define SPI_FRAME_LENGTH (1)
Uint16 spiWriteBuff[3]={0,0,0};
Uint16 spiReadBuff[1];
/
void main(void)
{
Int16 status;
printf("CSL SPI Test\n\n");
Int16 status = CSL_TEST_FAILED;
Int16 result;
CSL_SpiHandle hSpi;
SPI_Config hwConfig;
volatile Uint32 looper;
volatile Uint16 value = 0;
volatile Uint16 delay;
spiWriteBuff[0]=0xA000;
spiWriteBuff[1]=0xA304;
result = SPI_init();
// I have set to PPMODE as MODE1 - All modes are there CSO to CS3
if(CSL_SOK != result)
{
status = CSL_TEST_FAILED;
return (status);
}
else
{
printf ("SPI Instance Initialize successfully\n");
}
hSpi = SPI_open(SPI_CS_NUM_2, 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_16;
hwConfig.frLen = SPI_FRAME_LENGTH;
hwConfig.wcEnable = SPI_WORD_IRQ_DISABLE;
hwConfig.fcEnable = SPI_FRAME_IRQ_DISABLE;
hwConfig.csNum = SPI_CS_NUM_2;
hwConfig.dataDelay = SPI_DATA_DLY_2;
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");
}
result= SPI_write(hSpi,spiWriteBuff,3);
if(CSL_SOK != result)
{
printf ("write failed");
}
else
{
printf ("write success\n");
}
while(1)
{
CSL_FINS(CSL_SPI_REGS->SPICMD2,SPI_SPICMD2_CSNUM,0x02);
CSL_FINS(CSL_SPI_REGS->SPICMD1,SPI_SPICMD1_FLEN,0x0);
/* Write Enable command */
CSL_FINS(CSL_SPI_REGS->SPIDR2,SPI_SPIDR2_DATA,0x3000);
CSL_FINS(CSL_SPI_REGS->SPIDR1,SPI_SPIDR1_DATA,0x0000);
/* set start CMD - Write */
CSL_FINS(CSL_SPI_REGS->SPICMD2,SPI_SPICMD2_CMD,0x02);
do { /* Check for Word Complete status */
value=CSL_FEXT(CSL_SPI_REGS->SPISTAT1,SPI_SPISTAT1_CC);
}while((value & 0x01) == 0x0);
do { /* Check for busy status */
value=CSL_FEXT(CSL_SPI_REGS->SPISTAT1,SPI_SPISTAT1_BSY);
}while((value & 0x01) == 0x01);
result=SPI_read(hSpi,spiReadBuff,CSL_SPI_BUF_LEN )
if(CSL_SOK != result)
{
printf ("read failed");
}
else
{
printf ("read success\n");
}
}
I have doubt whether we are making any configuration wrong.
}
The