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.

Cortex M4 SPI Interface with ADE7758

Hello All,

I am using Cortex M4 along with ADE7758.

I am not able to read any data from ADE7758. I can see CSn pin goes low when I initiate read operation from LM4F232, even i can see data and clock when I send address of the register to be read from ADE7758.

I have modified the code given in Stellarisware.

Below is the code I am using

void ade7758_receive(unsigned char add,unsigned char nobytes)
{
// volatile unsigned char i = 24,c2,c3;
// volatile unsigned long buf=0;
// volatile unsigned int k=1,c1;

volatile unsigned char c3;

unsigned long ulDataRx[NUM_SSI_DATA];
unsigned long ulindex;

c3=add;

//------------------------transmit address-------------
SSIDataPut(SSI0_BASE,c3);
while(SSIBusy(SSI0_BASE))
{
}
//-------------------------------------------------------


delay(10);


//------------------------------------------------------------------------------------
for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
{
//
// Receive the data using the "blocking" Get function. This function
// will wait until there is data in the receive FIFO before returning.
//
SSIDataGet(SSI0_BASE, &ulDataRx[ulindex]);

//
// Since we are using 8-bit data, mask off the MSB.
//
ulDataRx[ulindex] &= 0x00FF;

}
delay(10);
}

One more doubt i have. ADE7758 has 5VDC supply and Stellaris runs on 3.3V(I am using EVM of Cortex M4). Is that problem? But Cortex M4 datasheet mentiones about 5V tolerant GPIO. Is it rue for SPI interface?

With Regards,

Harshal 

  • SPI communication is simultaneously clocked in both directions.  As a master, whenever you send data, you also receive data (whether wanted or not).  The corollary is that to receive data you must send data.

    The typical flow for SPI data (from the master) is:

    1) Send command word

    2) Read and discard dummy response

    (repeat steps 1 and 2 as necessary if the command takes more than a single word)

    3) Send dummy word

    4) Read response word

    (repeat steps 3 and 4 until the transaction is complete).