Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

NiosII SPI read problem

Altera_Forum
Honored Contributor II
1,075 Views

Hello everyone! 

 

I am using the SPI core in niosII to connect my fpga to peripheral and I am experiencing problems only when I try to read data from the peripheral. I first write certain data to my peripheral and then read it back. The results only match in certain cases, but I know that the data was written to it correctly in all cases. By writing to status register of the peripheral I set its sampling rate. That's how I know that the data was written correctly. For instance, when I write to the status register 0x01 and then read back, the written and read data match. But when I write 0x02, the read data is 0x03, but I see that my peripheral samples data faster. Also, when I write 0x03, I get back also 0x03, but it samples faster than in previous case. When I write 0x04, 0x05, 0x06 and 0x07, I read back 0x07. When I write 0x08, 0x09, I read back 0x0F. So, it appears to me that the problem might lie in the configuration of the input pin used as MISO pin as it struggles to put it low after the high voltage level. In the assignment editor I configured MISO pin as input tri-stated, but it doesn't help. Does anyone have any suggestions where the problem comes from? 

 

Thanks very much in advance!
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
367 Views

If You're using SPI as master, then MISO pin must be INPUT (Master In Slave Out). Anyway, the clocking rate of the SCK signal is determined in core parameters and are not changeable afaik, so I doubt it's a speed issue.

0 Kudos
Altera_Forum
Honored Contributor II
367 Views

Thanks for the reply. I don't think either it is a speed issue. My SCK should be 10MHz and reducing the speed didn't solve the problem.

0 Kudos
Reply