AnsweredAssumed Answered

STM32F107VG PB3 - PB4 - PA15 Alternate Function Usage

Question asked by EYIGEL.Levent on Jul 13, 2012
Latest reply on Jan 16, 2016 by beals.william
Hello
I have to use PB3 - PB4 - PB5 alternate function for using SPI3 or SPI1
But these pins are looking on JTAG main function after reset on datasheet.
These pins are still  working on jtag main function  I can't change that.
How can I solve this problem  ?


SPI Configuration is :
 void sFLASH_Init(void)
{
  SPI_InitTypeDef SPI_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;


  
  
//  #ifdef USE_STM3210C_EVAL
////  /* Enable SPI3 Pins Software Remapping */
//  GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
//#endif


  /* Configure SPI_MASTER pins: SCK, MISO and MOSI */
  GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN | sFLASH_SPI_MISO_PIN | sFLASH_SPI_MOSI_PIN;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(sFLASH_SPI_GPIO_PORT, &GPIO_InitStructure);


   GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
   GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);
   
   
  /* 1 bit for pre-emption priority, 3 bits for subpriority */
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);


  /* Configure and enable SPI_MASTER interrupt -------------------------------*/
  NVIC_InitStructure.NVIC_IRQChannel = SPI3_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
 
  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_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_Init(sFLASH_SPI, &SPI_InitStructure);
  
 SPI_I2S_ITConfig(sFLASH_SPI, SPI_I2S_IT_TXE, ENABLE);
    /* Enable SPI_SLAVE RXNE interrupt */
  SPI_I2S_ITConfig(sFLASH_SPI, SPI_I2S_IT_RXNE, ENABLE);
    
  SPI_Cmd(sFLASH_SPI, ENABLE);
  
  sFLASH_CS_HIGH();
}

RCC Configuration :
void RCC_Configuration(void)
{

  /* PCLK2 = HCLK/2 */
  RCC_PCLK2Config(RCC_HCLK_Div2); 


/* Enable peripheral clocks --------------------------------------------------*/
#ifdef USE_STM3210C_EVAL
  /* Enable GPIO clock for SPI_MASTER and SPI_SLAVE */
  RCC_APB2PeriphClockCmd(sFLASH_SPI_GPIO_CLK | //SPI_SLAVE_GPIO_CLK |
                         RCC_APB2Periph_AFIO, ENABLE);
  
   RCC_APB2PeriphClockCmd(sFLASH_CS_GPIO_CLK | RCC_APB2Periph_AFIO ,ENABLE);
   
  /* Enable SPI_MASTER Periph clock */
  RCC_APB1PeriphClockCmd(sFLASH_SPI_CLK, ENABLE);  

#endif
}

Pin Defines are :
  #define sFLASH_SPI                                  SPI3
  #define sFLASH_SPI_CLK                        RCC_APB1Periph_SPI3
  #define sFLASH_SPI_SCK_PIN               GPIO_Pin_3                  
  #define sFLASH_SPI_MISO_PIN             GPIO_Pin_4                  
  #define sFLASH_SPI_MOSI_PIN             GPIO_Pin_5                  
  #define sFLASH_CS_PIN                          GPIO_Pin_1                
  #define sFLASH_SPI_GPIO_PORT          GPIOB                       
  #define sFLASH_SPI_GPIO_CLK              RCC_APB2Periph_GPIOB
  #define sFLASH_CS_GPIO_PORT             GPIOE
  #define sFLASH_CS_GPIO_CLK               RCC_APB2Periph_GPIOE



Outcomes