-deleted-
7 years, 1 month ago.

STM32L073 Problems Using SPI

Hello,

This is my first post in the forum. I hope it makes sense.

It has become evident that when I try to use the SPI function in the target NUCLEO-L073RZ there is a conflict that is not capture in the compiler. I have the blink sample project and then added only the SPI declaration, having done that, the LED blink stops working. please see below the code:

#include "mbed.h"
 
DigitalOut led1(LED1);

//Uncomment any of the following two lines and the program will crash
//SPI spi( SPI_MOSI, SPI_MISO, SPI_SCK );
//SPI spi( PA_7, PA_6, PA_5 );

Serial pc(USBTX, USBRX);


int main() {
    
    while (1) {
        led1 = !led1;
        wait(0.5);
    }
}

Thanks!

1 Answer

7 years, 1 month ago.

Please use <<code>> and <</code>> tags on separate lines around your posted code to keep it readable.

See the board documentation here. That shows that the LED1 is on the same pin as PA_5 SPI_SCLK and thus there is a conflict with the DigitalOut(LED1) declaration . This should have been documented more clearly. You can solve that by using another pin for SPI_SCLK (ie PB_3).

Removing the DigitalOut for the LED1 may not work. Some reports say that the SCLK signal level on PA_5 is too low when the LED is mounted and communications fail. You can only solve that by disconnecting the LED.

Accepted Answer

You can also remove the SB21 solder bridge to disconnect the LED.

posted by bco stm 20 Nov 2017