AnsweredAssumed Answered

STM32F446, SPI3 MOSI (PC1) doesn't work

Question asked by deliancourt.sebastie on Jul 7, 2015
Latest reply on Jul 9, 2015 by mhiri.nesrine
Hello everybody,

I face to a weird problem and any help could be decisive :) (and I will be grateful of course) 
I transfer a project which implement USB, I²C and SPI from STM32F407 to STM32F446 but I am unable to do work SPI3. Clock work well, but I have no signal on MOSI pin (PC1).

For test this I send in an infinity loop the byte 0xAA
uint8_t   dataWriteEnable[1] = {0xAA};
while (1)
{
   
  dataWriteEnable[0]=HAL_SPI_Transmit(&SpiHandle,dataWriteEnable,1,200);
 
           
}

My hardware initialisation is below (SPIx_SCK_GPIO_CLK_ENABLE(),MOSI and MISO...corresponding to GPIOC):
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{
GPIO_InitTypeDef  GPIO_InitStruct;
 
  if (hspi->Instance == SPIx)
  {
    /*##-1- Enable peripherals and GPIO Clocks #################################*/
    /* Enable GPIO TX/RX clock */
    SPIx_SCK_GPIO_CLK_ENABLE();
    SPIx_MISO_GPIO_CLK_ENABLE();
    SPIx_MOSI_GPIO_CLK_ENABLE();
    /* Enable SPI clock */
    //SPIx_CLK_ENABLE();
 
    /*##-2- Configure peripheral GPIO ##########################################*/
    /* SPI mosi GPIO pin configuration  */
    GPIO_InitStruct.Pin = GPIO_PIN_1;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
      
        //SPI CS GPIOC13 as chip select (output push pull)
    GPIO_InitStruct.Pin = SPIx_CS_PIN;
    GPIO_InitStruct.Pull = GPIO_PULLUP;//GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    HAL_GPIO_Init(SPIx_CS_GPIO_PORT, &GPIO_InitStruct);
            //CS = 1
        HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT, SPIx_CS_PIN,GPIO_PIN_SET);
         
        //W is on Port G
      GPIO_InitStruct.Pin = SPIx_W_PIN;
        GPIO_InitStruct.Mode      = GPIO_MODE_OUTPUT_PP;
        GPIO_InitStruct.Pull      = GPIO_PULLUP;
        GPIO_InitStruct.Speed     = GPIO_SPEED_FAST;
      HAL_GPIO_Init(SPIx_W_PORT, &GPIO_InitStruct);
        //w=1 (write enable)
        HAL_GPIO_WritePin(SPIx_W_PORT, SPIx_W_PIN,GPIO_PIN_SET);
        //hold is on Port I
      GPIO_InitStruct.Pin = SPIx_HOLD_PIN;
        GPIO_InitStruct.Mode      = GPIO_MODE_OUTPUT_PP;
        GPIO_InitStruct.Pull      = GPIO_PULLUP;
        GPIO_InitStruct.Speed     = GPIO_SPEED_HIGH;
      HAL_GPIO_Init(SPIx_HOLD_PORT, &GPIO_InitStruct);
        HAL_GPIO_WritePin(SPIx_HOLD_PORT, SPIx_HOLD_PIN,GPIO_PIN_SET);
         
  }
         
}

and my SPI inititalisation is :

int8_t configSPI(SPI_HandleTypeDef *hspi, uint32_t BaudRatePrescaler)
    {
      
 
        /*---------------Configure the SPI peripheral---------------------------*/
        /*---------------CPOL and CPHA must have the same value-----------------*/
 
        HAL_SPI_DeInit(hspi);
         
  /* Set the SPI parameters */
  SpiHandle.Instance               = SPIx;
  SpiHandle.Init.Mode = SPI_MODE_MASTER;
  SpiHandle.Init.BaudRatePrescaler = BaudRatePrescaler;
  SpiHandle.Init.Direction         = SPI_DIRECTION_2LINES;
  SpiHandle.Init.CLKPhase          = SPI_PHASE_1EDGE;
  SpiHandle.Init.CLKPolarity       = SPI_POLARITY_LOW;
  SpiHandle.Init.CRCCalculation    = SPI_CRCCALCULATION_DISABLED;
  SpiHandle.Init.CRCPolynomial     = 7;
  SpiHandle.Init.DataSize          = SPI_DATASIZE_8BIT;
  SpiHandle.Init.FirstBit          = SPI_FIRSTBIT_MSB;
  SpiHandle.Init.NSS               = SPI_NSS_SOFT;
  SpiHandle.Init.TIMode            = SPI_TIMODE_DISABLED;
 
  if(HAL_SPI_Init(hspi) != HAL_OK)
  {
   /* Initialization Error */
  return HAL_ERROR;
    }
 
    return HAL_OK;
    }

I really don't see why that does not work anymore. 

Outcomes