0
\$\begingroup\$

I am trying to establish an SPI Connection between a microcontroller (STM32 dev board, master) and a CPLD (slave). For a simple demo to test the connection, I was just trying to toggle the MISO pin everytime a set clock edge occurs. When I do this using the rising clock-edge, it works fine. I am using the saleae Logic 2 Logic Analyzer to view the data lines.

Here is what is looks like when I want to detect the rising edge of the clock:

enter image description here

As expected, the MISO line (red) toggles with every rising clock edge. However, this is what happens when changing to the falling_edge in my VHDL-code.

enter image description here

The pin toggles and immediately toggles back to the original state on the same falling edge, and sometimes he just misses the edges completely, not getting triggered at all. What might be a reason for this? The Pins I use are just GPIOs (also the clock. It is a slow clock of around 100 ms period), there is no filtering or anything else applied on the slave's side. The behaviour does also not change when I play around with the CPOL & CPHA-Settings in both the Microcontroller and the Logic Analyzer Software.

Edit: In the pictures I attached, the Chip Select line was high active. As soon as I change it to low active, the detection of falling edges suddenly works but the rising edges cause some glitches now. How could any of this be related to the state of the chip-select line?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Seems likely that it is detected but the pulse generated is too short for your analyzer to pick up. You'll probably need to share your VHDL code to get help analyzing the issue. \$\endgroup\$
    – Mat
    Commented Jun 28, 2021 at 9:40
  • \$\begingroup\$ The VHDL code for this example is just a simple edge-triggered flipflop that feeds the output back to the input and inverts it if falling_edge(clk) then MISO <= not MISO; end if; \$\endgroup\$
    – Philipp94
    Commented Jun 28, 2021 at 9:55
  • \$\begingroup\$ @Philipp94 No matter how trivial, please add the code to the question. \$\endgroup\$ Commented Jul 12, 2021 at 14:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.