K60 SPI Issues - No Data Received

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

K60 SPI Issues - No Data Received

跳至解决方案
3,115 次查看
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

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
2,482 次查看
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 项奖励
回复
3 回复数
2,483 次查看
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 项奖励
回复
2,482 次查看
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 项奖励
回复
2,482 次查看
egoodii
Senior Contributor III
0 项奖励
回复