2012-03-15 06:20 AM
Hi,
I am using STM32F100CBT6B for my development. my hardware engineer had created a custom board, so I am not using the eval board.My software will communite wil a LCD controller using SPI port. Previously I am using SPI2 and everything works fine. Now, we need to change from SPI2 to SPI1. I had already made all necessary changes, but I am still getting no output from MOSI and SCK pins.Here I am attaching my code for SPI1 initialization, do I missed out anything?SPI_InitTypeDef SPI_InitStructure;GPIO_InitTypeDef GPIO_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE);// Deinitializes the SPI1SPI_DeInit(SPI1);// Release reset of SPI1RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);// Configure SPI1_CLK and SPI1_MOSI pinsGPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_7;GPIO_Init(GPIOA, &GPIO_InitStructure);GPIO_PinRemapConfig(GPIO_Remap_SPI1,DISABLE);// SPI initSPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;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_32;SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial = 7;SPI_Init(SPI1, &SPI_InitStructure); // Enable SPI1SPI_Cmd(SPI1, ENABLE);while(1){ SPI_SendData(SPI1, 0xAB); delayms(200); SPI_SendData(SPI1, 0xCD); delayms(200);} #spi1 #spi #stm322012-03-16 08:26 AM
Hi,
if you will use the remap feature please enable the AFIO interface before the GPIO configuration using this function: /* Enable AFIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); by default you dont need to disable the SPI remap feature Regards mozra