2015-08-06 06:20 AM
Hi.
I'm using STM32F107VCT6 in a project. I need to remap the SPI1 signals to pins PB5 PA4/5/6. when i send the data from SPI1, i see the waves of MOSI but cannot see the wave of SCKL (PA5). why cannot see the waves of SCKL ? This is my configuration of SPI1 /*********************************************************************** ******************************************************************************/ void vSPI1_RCC_Configuration(void) { /*SPI1 clocks enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); /* GPIOB, GPIOA clocks enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, DISABLE); } /***************************************************************************//** @brief Configure GPIO settings ******************************************************************************/ void vSPI1_GPIO_Configuration(void) { /* Enable SPI1 Pins Software Remapping */ GPIO_PinRemapConfig(GPIO_Remap_SPI1, ENABLE); /* Configure SPI1 pins: SCK*/ SPI1_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; SPI1_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; SPI1_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &SPI1_GPIO_InitStructure); /* Configure SPI1 pins: MISO -------------------------------*/ SPI1_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 ; SPI1_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; SPI1_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &SPI1_GPIO_InitStructure); /* Configure SPI1 pins: Chip Select -------------------------------*/ SPI1_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; /* SPI chip select pin.*/ SPI1_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; SPI1_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &SPI1_GPIO_InitStructure); /* Configure SPI1 pins: MOSI-------------------------------*/ SPI1_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; SPI1_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; SPI1_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &SPI1_GPIO_InitStructure); } void vSPI1_NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); /* SPI1 IRQ Channel configuration */ NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); NVIC_SetPriorityGrouping(0); } void vSPI1_Initialization(void) { SPI_I2S_DeInit(SPI1); /* SPI1 Master configuration */ SPI1_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; // set to full duplex mode, separate MOSI and MISO lines SPI1_InitStructure.SPI_Mode = SPI_Mode_Master; // configuration for Master mode SPI1_InitStructure.SPI_DataSize = SPI_DataSize_8b; // one packet of data is 8 bits wide SPI1_InitStructure.SPI_CPOL = SPI_CPOL_High; /*SPI compatible interface is configured to operate in a system using CPHA = 1 and CPOL = 1*/ SPI1_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI1_InitStructure.SPI_NSS = SPI_NSS_Soft ; SPI1_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256 ; // SPI frequency is APB2 frequency / 4 ==>32Mhz/4= 8Mhz SPI1_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI1_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI1_InitStructure); /* Enable SPI1 */ SPI_Cmd(SPI1, ENABLE); } void vSPI1_IRQHandler(void) { /* Check the interrupt source */ if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET) { /* Disable the I2S3 TXE interrupt to end the communication */ SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, DISABLE); } /* Check the interrupt source */ if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_RXNE) == SET) { /* Disable the I2S3 TXE interrupt to end the communication */ SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_RXNE, DISABLE); } } please i need your helps many thanks, Zoubi.2015-08-31 05:55 AM
Hi Zoubi,
You choose to enable SPI1 pins software remapping, but you used only PB5 as remap pin for MOSI.If you select to have SPI1 remapping, it has to be applied for NSS/PA15, SCK/PB3, MISO/PB4 and MOSI/PB5.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-08-31 05:57 AM
As per RM0008, there is no partial remap allowed for SPI1.
-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.