Hi,
in a project I want to use MAX V (precisely: 5M40ZE64I5N) operating as a slave on SPI bus, so I've started to prepare a very simple module for communication over SPI bus. My device uses 5 lines:
nrst - reset, negative logic,
ncs - chip select, negative logic,
sck - clock,
mosi - input of data to MAX V,
miso - output of data from MAX V.
I have a strange problem with outputting data on the miso line. I'd appreciate any hint on what's the cause, please.
I'm using Quartus II 64-Bit Version 15.0.0 Build 145 04/22/2015 SJ Web Edition.
The code is attached. As you can see, the module gets ready for work once nrst is high and ncs gets low, then it should output data on the miso line, the data change on falling edge of clock sck. The data should be an sequence of alternating '1's and '0's, starting with a '1'. The input line mosi is ignored.
Quartus shows the RTL diagram that I'd expect to see:
The simulator (gate level simulation in ModelSim AE) says it should work as assumed:
however the oscilloscope shows something different:
![]()
yellow - sck (2V/div)
green - miso (2V/div)
time scale 20us/div (so it's ca. 120kbit/s)
The first bit is set correctly as '1', then the first falling edge triggers transition to '0', and the next falling edges are ignored. Why?
Best regards,
Adam