cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery and SPI3 reset clock signal

kevinhuang
Associate II
Posted on September 12, 2014 at 20:07

Greetings,

I'm working with the STM32F4 Discovery board and I'm trying to configure SPI3 as an SPI slave. However, I'm getting strange results when attempting to configure the CLK pin. After a reset, the pin that I'm using (PB3) generates its own clock signal, which persists until the SPI master drives the SS pin low for its first transaction. The signal lingers long enough for the rest of the transaction to get corrupted, however. Per the reference manual, I learned that SPI3 and the JTAG/SWD interface share some pins. Beyond changing the alternate function though, it doesn't seem like there's any way to explicitly disable the JTAG debugger. This didn't seem to work because I was already calling GPIO_PinAFConfig() to change the pin's alternate function. My solution was to use a different set of pins (PC10) and its SPI3_CLK alternate function instead because the AF0 for debugging wasn't present on them. However, despite changing the pin being used, I see similar behavior: a clock signal being generated on the SPI3_CLK pin before the first SPI transaction. Other things I've tried is disconnecting SB12 to disconnect PB3 from the SWO signal on CN2, and also removing devices U5 and U7 from the board just in case they were generating the signal, but still no luck. My initialization code is below:

GPIO_InitTypeDef gpio;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA |
RCC_AHB1Periph_GPIOB |
RCC_AHB1Periph_GPIOC, ENABLE);
/*
* SPI3 -> CMD
* Function DISCOVERY BOARD F427
* SS PA15 PA15
* CLK PC10 PB3
* MISO PC11 PB4
* MOSI PB5 PD6
*/
GPIO_PinAFConfig(GPIOA, GPIO_PinSource15, GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource5, GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SPI3);
gpio.GPIO_Pin = GPIO_Pin_15;
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Speed = GPIO_Speed_100MHz;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &gpio);
gpio.GPIO_Pin = GPIO_Pin_5;
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Speed = GPIO_Speed_100MHz;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &gpio);
gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Speed = GPIO_Speed_100MHz;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &gpio);
SPI_InitTypeDef spi;
NVIC_InitTypeDef nvic;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
/* SPI for CMD */
spi.SPI_Direction = SPI_Direction_2Lines_FullDuplex; 
spi.SPI_Mode = SPI_Mode_Slave;
spi.SPI_DataSize = SPI_DataSize_8b;
spi.SPI_CPOL = SPI_CPOL_Low;
spi.SPI_CPHA = SPI_CPHA_2Edge;
spi.SPI_NSS = SPI_NSS_Hard;
spi.SPI_FirstBit = SPI_FirstBit_MSB;
spi.SPI_CRCPolynomial = 0;
SPI_Init(SPI3, &spi);
SPI_Cmd(SPI3, ENABLE);

Nothing really jumps out at me as being explicitly wrong or different than the way I've configured the GPIO/SPI before, so at this point I'm out of ideas of what could be causing it. Has anyone dealt with something like this before or does someone know where this signal is coming from? #stm32f4 #discovery
0 REPLIES 0