cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RC SPI3 configuration

linas
Associate
Posted on January 14, 2014 at 09:16

Hello,

I can't get SPI3 on pins (PB3, PB4. PB5) working. On the scope I checked that SPI clock is running. But still I can't read MX25L6406E flash ID. Functions that handles flash commands are checked and is working on STM32F2.

Here below is my SPI3 configuration:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB |       RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);

GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);  

RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);

//SPI SCK 

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

//SPI MOSI

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

//SPI MISO

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

/* Configure FLASH_CS Control */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(GPIOC, &GPIO_InitStructure);

FL_CS_OFF;

 

  /* SPI configuration -------------------------------------------------------*/

  SPI_I2S_DeInit(SPI3);

  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; 

SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

SPI_InitStructure.SPI_CRCPolynomial = 7;

SPI_Init(SPI3, &SPI_InitStructure);

SPI_Cmd(SPI3, ENABLE);
4 REPLIES 4
Posted on January 14, 2014 at 09:26

> On the scope I checked that SPI clock is running.

Did you check also CS, MOSI and MISO?

JW
linas
Associate
Posted on January 14, 2014 at 12:55

Problem solved. I did not disabled TRACE_IO in the KEIL IDE file STM32DBG.INI. This pin is JTDO / TRACESWO PB3. This is the same pin dedicated for SPI clock. I checked before disabling TRACE_IO that there were no clock. 

nguyenvanhiep_hd1985
Associate II
Posted on June 10, 2014 at 06:32

Hi stail,

Please tell me how to disable TRACE_IO and config file STM32DBG.ini

Thanks,

Posted on June 10, 2014 at 15:56

I guess you'd look at the script, or a Configuration Wizard view, or simply not use the script, and perhaps disable the trace in the ''Trace'' pane of the Debugger Configuration/Setting

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..