Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 12 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:
Zooming in:
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:
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
8 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.
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 12 Dec 2016