cancel
Showing results for 
Search instead for 
Did you mean: 

SPI (Basics): Why do I get a signal at MISO (PB_4) when performing a write without any connection to this pin? I am using STM32F413 Discovery Board with mbed

jjens
Associate II

Hi everyone, I am trying to connect my STM32F413 Discovery Board to a MAX30003 ECG but without any success. So I checked the SPI signals with a scope and discovered that I measure a signal on the MISO line as soon as I use a write command. All pins (MISO, MOSI, SSL, SCLK) are only connected to the scope! I assume the MISO should be constant low (0V) without connection, but I measure a stable 3.3V signal (i.e. 0x15). So what have I done wrong? After several days searching I would be thankful for some hints to find my mistake…

Thanks, Jens

  1. include "mbed.h"
  2. SPI device(SPI_MOSI, SPI_MISO, SPI_SCK);
  3. DigitalOut chipselect(SPI_CS);
  4. int main() {
  5. int i = 0;
  6. while(1) {
  7. chipselect=0;
  8. device.write(i++);
  9. chipselect=1;
  10. wait_ms(50);
  11. }
  12. }

(I am using chipselect as my scope trigger)

7 REPLIES 7

If MISO is floating, there may be enough capacitive coupling between MOSI and MISO to "drive" a "signal" visible on oscilloscope. Try switching on a pullup or pulldown on MISO.

JW

jjens
Associate II

Hi Jan,

I tried pullups as well as a pulldowns: without any changes.

In the PinNames.h file the pin PB_4 is dedicated to SPI_MISO as well as to a debug pin "SYS_JTRST". But I didn't find anything about this variable.

I now guess there are some interactions to other funktions of the discovery board, may be an I2S bus...?

How can I make sure that the pin is only used by my SPI funktion?

Best Jens

jjens
Associate II

PS: When I try to use other SPI pins, I receive a pinmap mis-match error so that i can't change them.

I don't use mbed so won't help with that part - normally, you would use the appropriate GPIO_AFR to select the appropriate alternate function number for SPI (you can check whether it's set properly by reading back the GPIO registers).

Unless there's something connected to MISO there should be no activity on it if SPI is set to Master. Are you sure you are probing PB4 and not any neighbouring pin? Can you set it to GPIO Output and toggle it manually and observe?

JW

Could this relate to SWD/JTAG activity of PB3 (SWO) nee SPI_SCLK

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jjens
Associate II

Hi Jan,

I have double checked that I probe PB_4. Furthermore it is no problem to use it as a normal GPIO output without any strange behavior.

This signal at the MISO pin only (but constantly occurs) when I use “write�? from Class “SPI�?.

Any hint would be highly appreciated!

jjens
Associate II

On this board there seems to be no additional SPI Pins available at the Arduino headers. But pulling up the WiFi_SPI_CSN pin (PG_11) solved my problems.

Thanks to Clive and Jan,

Jens