2012-05-05 9:46 AM
I'm using STM32L151R8. I have SPI slave on SPI1 pins PB3-PB5 and CS on PA15. The SPI doesn't seem to work and i need to double check the warning about disabling the JTAG pins.
But STM32L151xx reference manual has funny text in chapter 24.4.2 Flexible SWJ-DP pin assignment:''For more details on how to disable SWJ-DP port pins, please refer to Section 24.4.2: Flexible SWJ-DP pin assignment.''.This leads back to the same chapter which doesn't say how should the JTAG is disabled.I have read that F1 series have function for that:GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable | GPIO_Remap_SWJ_NoJTRST, ENABLE);But how it is supposed to be done in STM32L151 ?? #stm32l-stm32l151-jtag-disable #stm32l151-spi1-problem #off-topic
2012-05-05 4:20 PM
But how it is supposed to be done in STM32L151 ??
a) You config the GPIO pins not to be in AF mode or b) Use GPIO_PinAFConfig() to park the AF mux at something other than GPIO_AF_SWJ or GPIO_AF_TRACE. You'll need to enable the SYSCFG clock for this to work, and use PinSource to designate each pin function individually.2012-05-06 12:22 PM
Ok, the option b was what i thought. But it had an error:
I called:GPIO_PinAFConfig(GPIOB, GPIO_Pin_3, GPIO_AF_SPI1);But should have called:GPIO_PinAFConfig(GPIOB, GPIO_PinSource3, GPIO_AF_SPI1);So got SPI working finally:)2013-01-11 5:04 AM
Hi all,
I am testing SPI on STM32L151CB and used PinA4-A7 for SPI1and it is not woking. This is my SPI configuration, GPIO_InitTypeDef GPIO_InitStructure; SPI_InitTypeDef SPI_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_SetBits(GPIOA, GPIO_Pin_4); 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_1Edge; 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(SPI1, &SPI_InitStructure); SPI_Cmd(SPI1, ENABLE); What is the problem with the code. Can anyone help me.2013-01-11 7:04 AM
The question is a bit Off Topic for this thread, in the future create a new thread when starting an unrelated topic.
You should perhaps initialize the GPIO structure more completely for a start GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);