Two SPI problem

Hi Sirs,

I am using two spi port for two serial data output .

One spi work fine on the spi1 or spi2.
The problem happen when spi1 and spi2 work together.
I found the data of spi1 will write to both spi1 and spi2 output, even, the spi2 never write any thing.

My hardware is NUCLEO-F446RE, and my codes is as below:

SPI spi1(PA_7, PA_6, PA_5);
SPI spi2(PB_5, PB_4, PB_3);

void ch1_complete(int event) {
   ch1_busy = false;

void ch2_complete(int event) {
    ch2_busy = false;

event_callback_t spi1_complete = ch1_complete; //  spi1 complete callback func.
event_callback_t spi2_complete = ch2_complete; //  spi2 complete callback func.

uint8_t buf1[32];
uint8_t buf2[32];

void my_spi_init() {
    spi1.format(8, 0);
    spi2_format(8, 0);

    // spi1.set_dma_usage(DMA_USAGE_ALWAYS);
    // spi2.set_dma_usage(DMA_USAGE_ALWAYS);

    ch1_busy = false;
    ch2_busy = false;

void ch1_transfer() {
    if ( ch1_busy == false && buf1_avaliable ) {
        ch1_busy = true;
        spi1.transfer<uint8_t>(buf1, sizeof(buf1), NULL, 0, spi1_complete);

void ch2_transfer() {
    if ( ch2_busy == false && buf2_available ) {
        ch2_busy = true;
        spi2.transfer<uint8_t>(buf2, sizeof(buf2), NULL, 0, spi2_complete);

Please Help.

BR Jason.

Both SPI are using the same SPI instance: SPI1


Keep your spi1 pins for SPI1
and change spi2 pins to use SPI2:

SPI spi2(PC_1, PC_2, PC_7);

Then the information from picture below is little bit misleading.

  • Pins PA_7, PA_6, PA_5 are marked as SPI1
  • Pins PB_5, PB_4, PB_3 are marked as SPI3

Maybe it can be used like PB_5_ALT0, PB_4_ALT0, PB_3_ALT0.

BR, Jan

OUps… I have updated the images