AnsweredAssumed Answered

K60 SPI Issues - No Data Received

Question asked by weblar on Jul 26, 2013
Latest reply on Jun 2, 2016 by EARL GOODRICH

I'm attempting to interface to a Microchip 25AA02E48 serial EEPROM via the SPI peripheral.

 

My code so far goes like this...

 

// Enable the SPI

SPI2->MCR &= ~SPI_MCR_MDIS_MASK;


SPI2->MCR = SPI_MCR_MSTR_MASK | SPI_MCR_CLR_RXF_MASK | SPI_MCR_CLR_TXF_MASK | SPI_MCR_PCSIS(1) | SPI_MCR_ROOE_MASK;

SPI2->CTAR[0] = SPI_CTAR_FMSZ(8) | SPI_CTAR_PDT(0) | SPI_CTAR_BR(3);

SPI2->CTAR[1] = SPI_CTAR_FMSZ(8) | SPI_CTAR_PDT(0) | SPI_CTAR_BR(3) | SPI_CTAR_ASC(2) | SPI_CTAR_DT(2);

 

// Read instruction - FIFO 1

SPI2->PUSHR = 0x03 | SPI_PUSHR_PCS(1) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT_MASK;

// Set the address to be the starting index of the MAC address - FIFO 2

SPI2->PUSHR = 0xFA | SPI_PUSHR_PCS(1) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT_MASK;

// Dummy byte to read the data back - FIFO 3

SPI2->PUSHR = 0x00 | SPI_PUSHR_PCS(1) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ_MASK;

while (!(SPI2->SR & SPI_SR_RFDF_MASK));

d = SPI2->POPR;

SPI2->SR |= SPI_SR_RFDF_MASK;

 

I'm using the SPI2 port mapped to PORTD and as far as I'm aware, there are no electrical issues. However, looking on an oscilloscope, I can see the data being shifted out on the SDO pin but nothing ever comes back on the SDI pin. Attached to this is a picture of the scope traces - CS, SDO and SCK are all active but the green SDI trace is floating.

 

Having checked the Microchip datasheet, I'm certain that I'm meeting all timing requirements with the clock phase and polarity being correct although I have tested all variations of this. The SCK is running at 4MHz (from 120MHz system clock) yet running down at 1.8MHz still makes no difference.

 

Any suggestions would be most welcome.

 

Best regards,

Kev

Attachments

Outcomes