10 years, 1 month ago.

I don't know how to debug

Hello,

i am using a nucleo f401 and i implemented/copied different programs for wiznet5100 and sd card. Both of them are working fine. But, when i bring them together, it is not working. Concrete: The spi communication between nucleo and the w5100 ist not working anymore (the yello led ist not blinking).

I am using different spi-pins for w5100 and sd card and the program itself is still running (endless lopp with a printf-message every 200ms). It seems, as write/read access to the spi are not executed but the program still runs.

I am new to c++ and i was "debugging" as best as possible to me. Now i am out of ideas. The code is quite long and i don't think it is useful to post here.

Any ideas, why my spi communication is not working within a bigger program? What should i try to find the problem? How can i find out, if the memory (or heap/stack/...) are to full?

Lots of questions. I know.

best regards Heiko

It could be memory, but often code has the habbit of crashing completely when it runs out of memory, and that is not the case. Which SPI pins are you using?

posted by Erik - 25 Mar 2014

For the w5100 it is "SPI w5100_spi(PA_7, PA_6, PA_5);" and ChipSelect is on PB_6. The SDcard is on "PB_15, PB_14, PB_10, PB_9". I think both of them are SPI1.

posted by Heiko Greiner 25 Mar 2014

1 Answer

10 years, 1 month ago.

That's why I wondered, and thats your problem: They are both SPI1, they are one and the same SPI periheral. You must either use different SPI peripherals, or use the same pins for both, and then it should go correctly with the chip select lines.

I don't have experience with the Nucleo boards, but I once had to do something similar on an LPC1768. On the LPC1768 if I wired one peripheral to a different set of clock lines, the output pins on both just worked in sync. So that will work fine for you (since most likely only one has its chip select active, it does not matter that they both are sending data). However the problem: A peripheral cannot read from two pins at once, it picks one of the two MISO pins, and ignores the other one.

Now you can manually change the pins using the register settings, but the mbed lib isn't going to do it. While it means rewiring for you, the solutions are either making sure they use different peripherals, or the same pins and just different chipselects.

Hi,

i tried it also with another SPI (should be on PB_15, PB_14, PB_10, PB_9). But the same behavoir. I think the problem will come also with a class without access to spi at all.

here is a version that works (without the SDFileSystem): http://mbed.org/users/hggerdd/code/eth_v16_prob/

And here a version that does not work (wiznet 5100 and sd card together): http://mbed.org/users/hggerdd/code/eth_v16_prob_sd/

With a nucleo 401 it is easy to test. After installation you have to wait 5 seconds (maybe switch on terminal on 115200baud) and you should see the Led1 on SPI_SCLK blinking (first program). In the second program, the led will not blink.

I was looking at the code for hours now. I could not find the problem. I still suppose it is something with the memory. Maybe i use the W5100Class wrong (with extern),

Maybe someone has a hint for me to look at.

best regards, heiko

posted by Heiko Greiner 27 Mar 2014

Well with the pins still on that program it won't work for sure. However with PB14, 15, etc, it shouldn't be a problem since it is not SPI1. But without the board myself I can't test it sadly, maybe someone else can.

posted by Erik - 28 Mar 2014