K60 SPI Issues - No Data Received

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K60 SPI Issues - No Data Received

Jump to solution
1,787 Views
weblar
Contributor V

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

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
1,154 Views
egoodii
Senior Contributor III

I see 9 clocks per 'access' (FMSZ+1), and the seam between each is 'short' (check ASC, DT, etc), so those probably aren't making the 25AA02E48 happy.

View solution in original post

0 Kudos
Reply
3 Replies
1,155 Views
egoodii
Senior Contributor III

I see 9 clocks per 'access' (FMSZ+1), and the seam between each is 'short' (check ASC, DT, etc), so those probably aren't making the 25AA02E48 happy.

0 Kudos
Reply
1,154 Views
sruthyuk
Contributor I

Hi,

Is that SPI is running by using bus clock(60 MHz)?? ..not the system clock ..then how could i generate a 30MHZ clock from bus clock using the SIM_CLKDIV1 register in MK60fx512?? Because i a trying to interface AD5421 DAC with k60. Here max spi clock frequency for dac is about 30MHz.

Regards,

Sruthy uk

0 Kudos
Reply
1,154 Views
egoodii
Senior Contributor III
0 Kudos
Reply