cancel
Showing results for 
Search instead for 
Did you mean: 

SPI3 not working

linas2
Associate II
Posted on September 05, 2012 at 21:45

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 pin

2 REPLIES 2
Posted on September 05, 2012 at 22:32

GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
xinjin
Associate II
Posted on March 13, 2013 at 09:52

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