Skip to main content
Kuikui
Associate III
February 20, 2011
Question

How to properly reset SPI

  • February 20, 2011
  • 17 replies
  • 3335 views
Posted on February 20, 2011 at 19:06

How to properly reset SPI

#spi2-usart3
This topic has been closed for replies.

17 replies

antonio239955
Associate
May 17, 2011
Posted on May 17, 2011 at 14:25

I have an application that I want to be able to update in the field. So I want a user friendly code to burn the new code in the device. However: this requirement came late so  Ihad all the code already working, including SPI and everything. Well to be short: I did nothing to change the code, I followed the IAP example from ST, placed it in lower memory, then recompiled the original code at a different location. The IAP ( in application programming) code loads and burns the application code and JUMPS to it. That was all!  I did absolutely no new effort on the old code. And there was no problem with the SPI and any other peripheral. So my idea, at your problem, is : first try to get the same code working in different locations, may be there is something that is not-relocatable and cannot work from the normal reset if not placed in the exact same position.
Kuikui
KuikuiAuthor
Associate III
May 17, 2011
Posted on May 17, 2011 at 14:25

Hi,

I come back to this topic, cause I'm facing this issue once again.

Sometimes, the SCK pin of SPI2 of my STM32F102R8 does not clock, while MOSI sends correct data.

What can cause the SCK pin of SPI2 not to clock ?

SPI2 is not remapped, is enabled in RCC, and the pin is in ''alternate push-pull 50MHz'' mode.

Only a hardware reset ( I mean powering the board down then up ) can really ''reset'' the bug, and make SPI working correctly.

upanie
Visitor II
May 13, 2013
Posted on May 14, 2013 at 00:04

Hi.

It was long time ago but have you found solution to this problem?

I have the same issue. My SPI2 SCK (GPIOB Pin13) simply stops clocking when i configure GPIOB Pin11 as RX for USART3. MOSI works fine but SCK is low all the time.

Maybe someone knows something about this strange ''feature''. Errata doesn't say a word about it.
Tesla DeLorean
Guru
May 13, 2013
Posted on May 14, 2013 at 01:16

How are you initializing USART3?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
upanie
Visitor II
May 14, 2013
Posted on May 14, 2013 at 09:45

It is not directly caused by USRT3 initialization

as it turned out

. I've found that SCK pin stops generating clock right after configuring pin 11 for USART3. When SPI2 works fine I do the following:

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_Init(GPIOB,&GPIO_InitStructure);

and SCK stops. When I configure Pin 11 before configuring SPI2 everything works. So for now problem is resolved but this seams to be a hardware bug or maybe I'm missing something important.
waclawek.jan
Super User
May 14, 2013
Posted on May 14, 2013 at 09:58

Can you please start a new thread, post a minimal but complete compilable example of code which produces the error, together with stating what device are you using.

JW

upanie
Visitor II
May 20, 2013
Posted on May 20, 2013 at 12:32

I will do it as soon as i have time.