K60 SPI Issues - No Data Received

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K60 SPI Issues - No Data Received

ソリューションへジャンプ
3,120件の閲覧回数
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,487件の閲覧回数
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,488件の閲覧回数
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,487件の閲覧回数
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,487件の閲覧回数
egoodii
Senior Contributor III
0 件の賞賛
返信