4 years, 11 months ago.

SPI interface for STM32F103C8T6 behaving oddly with 16-bit transfer

Hi all,

Update: this question was raised as a bug/suggestion.

I am using the online compiler targeting the "NUCLEO-F103RB" board and importing the mbed-STM32F103C8T6 library.

Here's the test program I am using to test 16-bit SPI transfer on the STM32F103C8T6 board covered here:

include the mbed and mbed-STM32F103C8T6 libraries with this snippet

#include "stm32f103c8t6.h"
#include "mbed.h"

DigitalOut  myled(LED1);
SPI         mySPI(PB_15, NC, PB_13);
DigitalOut  cs(PB_12);

void send_words ()
{
    int i;

    for (i = 0; i < 5; i++)
        mySPI.write(0xffff);
}

int main() {
    confSysClock();         /* Configure system clock (72MHz HSE clock, 48MHz USB clock) */

    cs = 1;
    mySPI.format(16, 3);
    mySPI.frequency(1000000);
    cs = 0;

    while(1) {
        send_words();
        myled = !myled;
        wait(1);
    }
}

Here's a capture of the resulting signal: /media/uploads/luigidifraia/logic_spi_01.png

Zooming in: /media/uploads/luigidifraia/logic_spi_01_zoom.png

What is odd is that after each expected 16-bit transfer of the word 0xffff there's a second unexpected 16-bit transfer of the word 0x0000. So in total 10 words are transferred, instead of 5, every second.

For comparison, here's what happens if I use 8-bit SPI transfer:

/media/uploads/luigidifraia/logic_spi_02.png

The latter is the expected behaviour. Would anybody be able to advise whether this is a known issue, please?

Thank you.

Cheers,

Luigi

1 Answer

4 years, 11 months ago.

Hello Luigi,
It seems that this behavior isn't specific just to the STM32F103C8T6 boards because I have got exactly the same results when running your code (without using the mbed-STM32F103C8T6 library) on a NUCLEO-STM32F103RB board. Most likely this is caused by a bug in the mbed library.

Accepted Answer

Thanks a lot Zoltan for taking the time to verify this. Would you recommend I accept yours as an answer and close my question, or is it OK if I take a few days to figure out how to raise the bug request against the mbed library and possibly create a pull request if I manage to find the bug itself?

posted by Luigi Di Fraia 12 Dec 2016

Of course it's OK to keep it open and report the bug to mbed team 'officially'. I'm sorry but I am not able to help you with that since I do not know what the 'official' way suppose to be.

posted by Zoltan Hudak 12 Dec 2016