AnsweredAssumed Answered

No CLK on SPI2 STM32F407VG

Question asked by honeycutt.matt on Jan 25, 2014
Latest reply on Jan 27, 2014 by waclawek.jan

I'm trying to figure out why i'm not getting a CLK on SPI2. In this below example MOSI sends the data, but I'm getting no clock. (Verified with a logic analyzer)

My Pinout:
SCK - PB10

You can download my CooCox Project from here

I've got to be overlooking something simple. 

Thanks in advance!
int main(void) {
    SPI_I2S_SendData(SPI2, 0x04);
void SetupSPI() {
    GPIO_InitTypeDef initStructure;
    SPI_InitTypeDef spiInitStructure;
    //RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
    GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_SPI2); //SCK
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource2, GPIO_AF_SPI2); //MISO
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource3, GPIO_AF_SPI2); //MOSI
    initStructure.GPIO_Mode = GPIO_Mode_AF;
    initStructure.GPIO_Speed = GPIO_Speed_50MHz;
    initStructure.GPIO_OType = GPIO_OType_PP;
    initStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
    initStructure.GPIO_Pin = GPIO_Pin_10; //SCK
    GPIO_Init(GPIOB, &initStructure);
    initStructure.GPIO_Pin = GPIO_Pin_2; //MISO
    GPIO_Init(GPIOC, &initStructure);
    initStructure.GPIO_Pin = GPIO_Pin_3; //MOSI
    GPIO_Init(GPIOC, &initStructure);
    initStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_7; //CS and RST
    initStructure.GPIO_Mode = GPIO_Mode_OUT;
    initStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOC, &initStructure);
    initStructure.GPIO_Pin = GPIO_Pin_9; //DC Low = CMD - High = Data
    GPIO_Init(GPIOC, &initStructure);
    spiInitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
    spiInitStructure.SPI_DataSize = SPI_DataSize_8b; // 8 Bits per transfer
    spiInitStructure.SPI_CPOL = SPI_CPOL_Low; //Clock is low when inactive
    spiInitStructure.SPI_CPHA = SPI_CPHA_1Edge; // Data is valid on clock leading edge
    spiInitStructure.SPI_NSS = SPI_NSS_Soft;
    spiInitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16;
    spiInitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //Most significant bit first
    spiInitStructure.SPI_CRCPolynomial = 7;
    spiInitStructure.SPI_Mode = SPI_Mode_Master;
    SPI_Init(SPI2, &spiInitStructure);
    SPI_Cmd(SPI2, ENABLE);