Dear Friends!
Warm Greetings! I am working with evmc5515 and afe4490.. I was writing the data in afe 4490 registers ..but i couldnt verify by read back those values from afe4490 registers .
i wrote the code for afe 4490 spi communication as belows:
What i did is
1) GPIO pin output high for afe4490 reset and afe_pdn:
GPIO_DIR0_ADDR = GPIO_DIR0_ADDR | 0x0810;
GPIO_DOUT0_ADDR = GPIO_DIR0_ADDR | 0x0810;
2). SPI initialization :
SpiClkRate =1000000;
WordLen = 24;
FrameLen = 49;
SPI_INIT(SpiClkRate, WordLen, FrameLen);
LLC_SPI_FLenSet(FrameLen);
3). default data writing in afe registers
CSL_SPI_REGS->SPIDR2 = 0x0000;
CSL_SPI_REGS->SPIDR1 = 0x0000;
result = LLC_SPI_CmdSet(SPI_WRITE);
wait(50);
CSL_SPI_REGS->SPIDR2 = 0x0100;
CSL_SPI_REGS->SPIDR1 = 0x1770;
result = LLC_SPI_CmdSet(SPI_WRITE);
wait(50);
CSL_SPI_REGS->SPIDR2 = 0x0200;
CSL_SPI_REGS->SPIDR1 = 0x1DAF;
result = LLC_SPI_CmdSet(SPI_WRITE);
wait(50);
CSL_SPI_REGS->SPIDR2 = 0x0300;
CSL_SPI_REGS->SPIDR1 = 0x1770;
result = LLC_SPI_CmdSet(SPI_WRITE);
wait(50);
..
..
..
4.) for SPI read
4.1) set read bit in AFE register 0:
Status = SPI_INIT(SpiClkRate, 16, 2);
CSL_SPI_REGS->SPIDR2 = 0x0000;
CSL_SPI_REGS->SPIDR1 = 0x0001;
result = LLC_SPI_CmdSet(SPI_WRITE);
wait(50);
4.2 ) specify the address 0x01h for data read:
Status = SPI_INIT(SpiClkRate, 16, 1);
CSL_SPI_REGS->SPIDR2 = 0x0100;
CSL_SPI_REGS->SPIDR1 = 0x0000;
result = LLC_SPI_CmdSet(SPI_WRITE);
4.3) SPi Read
CSL_SPI_REGS->SPIDR1 = 0x00;
CSL_SPI_REGS->SPIDR2 = 0x00;
LLC_SPI_CmdSet(SPI_READ);
do {
LLC_SPI_StatusRead(&spiStatusReg);
spiBusStatus = (spiStatusReg & SPI_STATUS_BUSY_MASK);
wordComplete = (spiStatusReg & SPI_STATUS_WC_MASK );
} while((SPI_STATUS_BUSY == spiBusStatus) && (wordComplete != SPI_WORD_COMPLETE));
ReadVal = CSL_SPI_REGS->SPIDR2;
ReadVal = ReadVal << 16;
ReadVal |= CSL_SPI_REGS->SPIDR1 ;
ReadVal &= mask;
readbufIndex] = ReadVal;
During step by step execution, what i observed is:
a. afe reset and afe pdn pins are high
b. Led blinking in this probe(when data writing in afe registers)
c. i could see spi clk , spisimo and spiste signals in scope
** d: readVal value is zero (its always showing zero)
i want to know where i did the mistake and the flow is right or not ?!