cancel
Showing results for 
Search instead for 
Did you mean: 

How to use SPI3 of STM32F103RCT6 (no have SCK)

Kim Sang Hyouk
Associate II

Dear All

Nice to meet you.

At First My english is poor. Please understand me.

I want use M95512 (EEPROM) with STM32F103RCT6 SPI3

but now I check Oscilloscope SCK, MOSI, MISO. Only work MOSI have signal

now no work SCK.... How to Init. SPI3

Please check my code.

Thank you ^.^

void SPI3_Config(void){
  
  SPI_InitTypeDef SPI_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
 
  SPI_Cmd(SPI3, DISABLE);
 
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
  GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);  
  
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
  
  //                            SCK          MOSI
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  //                            MISO
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 
  GPIO_Init(GPIOB, &GPIO_InitStructure);  
  
  // Configure CS pin as output floating
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
 
  // 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_8;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_Init(SPI3, &SPI_InitStructure);
  SPI_Cmd(SPI3, ENABLE);
  
  SPI_SSOutputCmd(SPI3,DISABLE);
 
  SPI_I2S_ITConfig(SPI3,SPI_I2S_IT_RXNE,ENABLE);  
}

 ​

3 REPLIES 3

GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);

I don't use 'F1, but looking into RM0008 it appears that SPI3_SCK is at PB3 when SPI3 is *not* remapped.

0690X000006C00SQAS.png

Kim Sang Hyouk
Associate II

Thank you ~ ^.^  waclawek.jan

I was  use like this. but work same (no SCK)

  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
//  GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE); 

I was use like this. but also  work same (no SCK)

//  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
//  GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);  

When I use SPI1 with M95512(EEPROM) than ... It's work...

But..... change SPI3..... no work...

Please check it.

Kim Sang Hyouk
Associate II

​Now Can Work~....

I change position. end of GPIO Init