2012-09-05 12:45 PM
Hello, ai am trying to comunicate with external DAC and having some hard time using SPI3 in GPIOC port (12,10 and 11 for CS)
i have no problem with SPI2, but SPI2 is for LCD touschreen so i want to make new one; so far i found mistake in standartlib:* ===================================================================
* How to use this driver * =================================================================== * * 1. Enable peripheral clock using the following functions * RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE) for SPI1 * RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE) for SPI2 * RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE) for SPI3. so far code looks like this, CS is working but no CLK or MOSI (i need just Tx)GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC , ENABLE); /*!< SPI pins configuration *************************************************/ /*!< Connect SPI pins to AF5 */ GPIO_PinAFConfig(GPIOC, GPIO_Pin_12, GPIO_AF_SPI3 ); GPIO_PinAFConfig(GPIOC, GPIO_Pin_10, GPIO_AF_SPI3); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; /*!< SPI SCK pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_Init(GPIOC, &GPIO_InitStructure); /*!< SPI MOSI pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOC, &GPIO_InitStructure); SPI_InitTypeDef SPI_InitStructure; GPIO_SetBits(GPIOC, GPIO_Pin_11); /*!< SPI configuration */ SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; 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(SPI3, &SPI_InitStructure); SPI_Cmd(SPI3, ENABLE); for transmit 16b integer i use:GPIO_ResetBits(GPIOC, GPIO_Pin_11);
while (SPI_I2S_GetFlagStatus(SPI3, SPI_FLAG_TXE) == RESET) {} SPI_I2S_SendData(SPI3, output); GPIO_SetBits(GPIOC, GPIO_Pin_11); any ideas why i have no CLK or MOSI output i am using STM32F417VGT6 144 pin2012-09-05 01:32 PM
GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);2013-03-13 01:52 AM
Hello,
Have you solved the problems? I met the same problem with you recently. I use the F4-Discovery Board. The SPI3 is also connected to the audio dec on the board with I2S mode. Thanks for your help. Jin