Question
SPI3 conflict with JATG on stm32f103RET
Posted on June 16, 2015 at 17:58
Hi
I saw lots of discussions and solutions about working with SPI3 by disabling JTAG on STM32F103 devices. But I already have problem with it.I am using SWD for program and debug the mcu with Keil and the same code is working flawlessly for SPI1/SPI2.here is my initialization code:&sharpdefine SD_SCK_PIN GPIO_Pin_3&sharpdefine SD_SCK_PRT GPIOB&sharpdefine SD_MOSI_PIN GPIO_Pin_5&sharpdefine SD_MOSI_PRT GPIOB&sharpdefine SD_MISO_PIN GPIO_Pin_4&sharpdefine SD_MISO_PRT GPIOB&sharpdefine SD_CS_PIN GPIO_Pin_7&sharpdefine SD_CS_PRT GPIOC&sharpdefine SD_SPI SPI3void SPI_SDMode(void){ SPI_InitTypeDef SPI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO ,ENABLE ); RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI3,ENABLE ); /* PB3=CLK, PB4=MISO, PB5=MOSI alternate function */ GPIO_InitStructure.GPIO_Pin = SD_SCK_PIN | SD_MOSI_PIN | GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(SD_SCK_PRT, &GPIO_InitStructure); /* Configure PC7 as CS open drain push-pull output */ GPIO_SetBits(SD_CS_PRT, SD_CS_PIN); //set high. GPIO_InitStructure.GPIO_Pin = SD_CS_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(SD_CS_PRT, &GPIO_InitStructure); /* SPI configuration */ SPI_Cmd(SD_SPI, DISABLE); //disable SPI for configuration. 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_128; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SD_SPI, &SPI_InitStructure); /* Enable SPI */ SPI_Cmd(SD_SPI, ENABLE); //-------------------------------------- GPIO_SetBits(SD_CS_PRT, SD_CS_PIN); /* Loop while DR register in not emplty */ while(SPI_I2S_GetFlagStatus(SD_SPI, SPI_I2S_FLAG_TXE) == RESET); /* Send byte through the SPI peripheral */ SPI_I2S_SendData(SD_SPI, 0xff); /* Wait to receive a byte */ while(SPI_I2S_GetFlagStatus(SD_SPI, SPI_I2S_FLAG_RXNE) == RESET); /* Return the byte read from the SPI bus */ SPI_I2S_ReceiveData(SD_SPI); //----------------------------------------------------end GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); }can anyone help me with this matter? #spi3 #stm32f103 #jtag