cancel
Showing results for 
Search instead for 
Did you mean: 

SPI1 question ?

antonius
Senior
Posted on September 13, 2015 at 12:38

Guys,

I want to use SPI1 for communicating with VS1... Is my configuration right ?

#if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL) && !defined (USE_STM3210C_EVAL)&& !defined (USE_STM32100E_EVAL)
//#define USE_STM3210B_EVAL
#define USE_STM3210E_EVAL
//#define USE_STM32100E_EVAL
//#define USE_STM3210C_EVAL
#endif
/* Define the STM32F10x hardware depending on the used evaluation board */
#if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) || defined (USE_STM32100E_EVAL)
#define SPI_MASTER SPI1
#define SPI_MASTER_CLK RCC_APB2Periph_SPI1
#define SPI_MASTER_GPIO GPIOA
#define SPI_MASTER_GPIO_CLK RCC_APB2Periph_GPIOA 
#define SPI_MASTER_PIN_NSS GPIO_Pin_4
#define SPI_MASTER_PIN_SCK GPIO_Pin_5
#define SPI_MASTER_PIN_MISO GPIO_Pin_6
#define SPI_MASTER_PIN_MOSI GPIO_Pin_7
#define SPI_SLAVE SPI2
#define SPI_SLAVE_CLK RCC_APB1Periph_SPI2
#define SPI_SLAVE_GPIO GPIOB
#define SPI_SLAVE_GPIO_CLK RCC_APB2Periph_GPIOB 
#define SPI_SLAVE_PIN_NSS GPIO_Pin_12
#define SPI_SLAVE_PIN_SCK GPIO_Pin_13
#define SPI_SLAVE_PIN_MISO GPIO_Pin_14
#define SPI_SLAVE_PIN_MOSI GPIO_Pin_15 
#define SPI_SLAVE_DMA DMA1
#define SPI_SLAVE_DMA_CLK RCC_AHBPeriph_DMA1 
#define SPI_SLAVE_Rx_DMA_Channel DMA1_Channel4
#define SPI_SLAVE_Rx_DMA_FLAG DMA1_FLAG_TC4
#define SPI_SLAVE_Tx_DMA_Channel DMA1_Channel5
#define SPI_SLAVE_Tx_DMA_FLAG DMA1_FLAG_TC5 
#define SPI_SLAVE_DR_Base 0x4000380C
#elif defined (USE_STM3210C_EVAL)
#define SPI_MASTER SPI3 /* SPI pins are remapped by software */
#define SPI_MASTER_CLK RCC_APB1Periph_SPI3
#define SPI_MASTER_GPIO GPIOC
#define SPI_MASTER_GPIO_NSS GPIOA
#define SPI_MASTER_GPIO_CLK (RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA) 
#define SPI_MASTER_PIN_NSS GPIO_Pin_4
#define SPI_MASTER_PIN_SCK GPIO_Pin_10
#define SPI_MASTER_PIN_MISO GPIO_Pin_11
#define SPI_MASTER_PIN_MOSI GPIO_Pin_12
#define SPI_SLAVE SPI2
#define SPI_SLAVE_CLK RCC_APB1Periph_SPI2
#define SPI_SLAVE_GPIO GPIOB
#define SPI_SLAVE_GPIO_CLK RCC_APB2Periph_GPIOB
#define SPI_SLAVE_PIN_NSS GPIO_Pin_12
#define SPI_SLAVE_PIN_SCK GPIO_Pin_13
#define SPI_SLAVE_PIN_MISO GPIO_Pin_14
#define SPI_SLAVE_PIN_MOSI GPIO_Pin_15
#define SPI_SLAVE_DMA DMA1
#define SPI_SLAVE_DMA_CLK RCC_AHBPeriph_DMA1
#define SPI_SLAVE_Rx_DMA_Channel DMA1_Channel4
#define SPI_SLAVE_Rx_DMA_FLAG DMA1_FLAG_TC4
#define SPI_SLAVE_DR_Base 0x4000380C 
#endif

I want to use XCS = NSS = PA4 SCK = PA5 MOSI = PA6 MISO = PA7 Here's the GPIO config :

/**
* @brief Configures the different GPIO ports.
* @param None
* @retval None
*/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//define DREQ,XDCS,XRST PORT
/*!< GPIOC and GPIOD Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
/*!< Configure PE.08, PE.09 XDCS, XRST */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*Configure GPIO pin : PE7 as input, DREQ */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOE, &GPIO_InitStructure);
#ifdef USE_STM3210C_EVAL
/* Enable SPI3 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
/* Configure SPI_MASTER pins: SCK and MOSI */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_SCK | SPI_MASTER_PIN_MOSI;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO, &GPIO_InitStructure);
/* Configure SPI_MASTER NSS pin */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_NSS;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO_NSS, &GPIO_InitStructure);
#else
/* Configure SPI_MASTER pins: NSS, SCK and MOSI */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_NSS | SPI_MASTER_PIN_SCK | SPI_MASTER_PIN_MOSI;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO, &GPIO_InitStructure);
#endif
/* Configure SPI_SLAVE pins: NSS, SCK and MISO*/
GPIO_InitStructure.GPIO_Pin = SPI_SLAVE_PIN_NSS | SPI_SLAVE_PIN_SCK;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(SPI_SLAVE_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = SPI_SLAVE_PIN_MISO;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_SLAVE_GPIO, &GPIO_InitStructure);
}

Thanks for the info
10 REPLIES 10
Posted on September 13, 2015 at 17:09

I'd start by uncluttering the code, so you're clear on exactly what's being configured, ie lose the selective compilation, and ideally the defines.

You're not using SPI3, and you're not remapping hardware.

You don't look to be enabling the GPIO / SPI1 clocks you need.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on September 14, 2015 at 00:27

I'm confuse on using SPI1 here's the code :

Which one is it for using SPI1 with the right clock on RCC ? I don't want to use SPI3, only NSS,SCK,MOSI,MISO from SPI1..... I'm using my own board.... thanks

/**
* @brief Configures the different system clocks.
* @param None
* @retval None
*/
void RCC_Configuration(void)
{
/* PCLK2 = HCLK/2 */
RCC_PCLK2Config(RCC_HCLK_Div2); 
/* Enable peripheral clocks --------------------------------------------------*/
/* Enable SPI_SLAVE DMA clock */
RCC_AHBPeriphClockCmd(SPI_SLAVE_DMA_CLK, ENABLE);
#ifdef USE_STM3210C_EVAL
/* Enable GPIO clock for SPI_MASTER and SPI_SLAVE */
RCC_APB2PeriphClockCmd(SPI_MASTER_GPIO_CLK | SPI_SLAVE_GPIO_CLK |
RCC_APB2Periph_AFIO, ENABLE);
/* Enable SPI_MASTER Periph clock */
RCC_APB1PeriphClockCmd(SPI_MASTER_CLK, ENABLE);
#else
/* Enable SPI_MASTER clock and GPIO clock for SPI_MASTER and SPI_SLAVE */
RCC_APB2PeriphClockCmd(SPI_MASTER_GPIO_CLK | SPI_SLAVE_GPIO_CLK |
SPI_MASTER_CLK, ENABLE);
#endif
/* Enable SPI_SLAVE Periph clock */
RCC_APB1PeriphClockCmd(SPI_SLAVE_CLK, ENABLE);
}
/**
* @brief Configures the different GPIO ports.
* @param None
* @retval None
*/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//define DREQ,XDCS,XRST PORT
/*!< GPIOC and GPIOD Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
/*!< Configure PE.08, PE.09 XDCS, XRST */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*Configure GPIO pin : PE7 as input, DREQ */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOE, &GPIO_InitStructure);
#ifdef USE_STM3210C_EVAL
/* Enable SPI3 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
/* Configure SPI_MASTER pins: SCK and MOSI */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_SCK | SPI_MASTER_PIN_MOSI;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO, &GPIO_InitStructure);
/* Configure SPI_MASTER NSS pin */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_NSS;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO_NSS, &GPIO_InitStructure);
#else
/* Configure SPI_MASTER pins: NSS, SCK and MOSI */
GPIO_InitStructure.GPIO_Pin = SPI_MASTER_PIN_NSS | SPI_MASTER_PIN_SCK | SPI_MASTER_PIN_MOSI;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_MASTER_GPIO, &GPIO_InitStructure);
#endif
/* Configure SPI_SLAVE pins: NSS, SCK and MISO*/
GPIO_InitStructure.GPIO_Pin = SPI_SLAVE_PIN_NSS | SPI_SLAVE_PIN_SCK;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(SPI_SLAVE_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = SPI_SLAVE_PIN_MISO;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPI_SLAVE_GPIO, &GPIO_InitStructure);
}

Posted on September 14, 2015 at 01:00

Ok, this will have a lot more clarity if you remove the unused code, and stop using the defines.

SPI1 is on APB2

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
euan
Associate
Posted on September 14, 2015 at 06:46

I would suggest you use the STM32CubeMX software as a basis, especially when you have a custom board.

It will create a lot of the setup code for you and bring in the SPI HAL drivers.

As an example the code below was all generated by the CubeMX software for an STM32F030 and put into the main.c file of the project.

I just added the SPI peripheral and setup the DMA settings via the software wizards.

Once the project is created you would then call the SPI functions from main to speak to the VS1053. e.g. HAL_SPI_TransmitReceive_DMA()

main.c output.....

#include ''stm32f0xx_hal.h''

SPI_HandleTypeDef hspi1;

DMA_HandleTypeDef hdma_spi1_rx;

DMA_HandleTypeDef hdma_spi1_tx;

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_DMA_Init(void);

static void MX_SPI1_Init(void);

int main(void)

{

  HAL_Init();

  /* Configure the system clock */

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_DMA_Init();

  MX_SPI1_Init();

  while (1)

  {

  }

}

/** System Clock Configuration

*/

void SystemClock_Config(void)

{

  RCC_OscInitTypeDef RCC_OscInitStruct;

  RCC_ClkInitTypeDef RCC_ClkInitStruct;

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

  RCC_OscInitStruct.HSIState = RCC_HSI_ON;

  RCC_OscInitStruct.HSICalibrationValue = 16;

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

  HAL_RCC_OscConfig(&RCC_OscInitStruct);

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;

  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;

  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

}

/* SPI1 init function */

void MX_SPI1_Init(void)

{

  hspi1.Instance = SPI1;

  hspi1.Init.Mode = SPI_MODE_MASTER;

  hspi1.Init.Direction = SPI_DIRECTION_2LINES;

  hspi1.Init.DataSize = SPI_DATASIZE_4BIT;

  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;

  hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;

  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;

  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

  hspi1.Init.TIMode = SPI_TIMODE_DISABLED;

  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;

  hspi1.Init.CRCPolynomial = 10;

  hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;

  hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLED;

  HAL_SPI_Init(&hspi1);

}

/** 

  * Enable DMA controller clock

  */

void MX_DMA_Init(void) 

{

  /* DMA controller clock enable */

  __DMA1_CLK_ENABLE();

  /* DMA interrupt init */

  HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0);

  HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);

}

/** Pinout Configuration

*/

void MX_GPIO_Init(void)

{

  /* GPIO Ports Clock Enable */

  __GPIOA_CLK_ENABLE();

}

antonius
Senior
Posted on September 14, 2015 at 10:50

I have made from STM32CubeMx, please correct me if I've made a mistake ? thanks

/** System Clock Configuration
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
__HAL_RCC_PLLI2S_ENABLE();
}
/* SPI1 init function */
void MX_SPI1_Init(void)
{
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
hspi1.Init.CRCPolynomial = 10;
HAL_SPI_Init(&hspi1);
}
/* USART1 init function */
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&huart1);
}
/** Configure pins as 
* Analog 
* Input 
* Output
* EVENT_OUT
* EXTI
* Free pins are configured automatically as Analog (this feature is enabled through 
* the Code Generation settings)
*/
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pins : PE2 PE3 PE4 PE10 
PE11 PE12 PE13 PE14 
PE15 PE0 PE1 */
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_10 
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PE5 PE6 PE8 PE9 */
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PC13 PC14 PC15 PC0 
PC1 PC2 PC3 PC4 
PC5 PC6 PC7 PC8 
PC9 PC10 PC11 PC12 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0 
|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 
|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PA0 PA1 PA2 PA3 
PA8 PA11 PA12 PA13 
PA14 PA15 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 
|GPIO_PIN_8|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 
|GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB0 PB1 PB2 PB10 
PB11 PB12 PB13 PB14 
PB15 PB3 PB4 PB5 
PB6 PB7 PB8 PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10 
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
|GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pin : PE7 */
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PD8 PD9 PD10 PD11 
PD12 PD13 PD14 PD15 
PD0 PD1 PD2 PD3 
PD4 PD5 PD6 PD7 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 
|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
/* USER CODE END 6 */
}
#endif
/**
* @}
*/ 
/**
* @}
*/

antonius
Senior
Posted on September 14, 2015 at 23:44

How can I use SDIO for SDcard on STM32CubeMX ?

I set FATFs on but I can't find SDIO setting where is it ? thanks

Amel NASRI
ST Employee
Posted on September 15, 2015 at 12:55

Hi h.rick,

Is the SPI issue fixed after usage of CubeMX?

What device did you selected exactly? SDIO should be available in the pinout tab.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

antonius
Senior
Posted on September 15, 2015 at 16:24

I haven't got time testing SPI1, but it's ok when I compiled it,

I'm using STM32F107VCT6.....how can I use SDIO on STM32CubeMX with it ?

I can't see the option for using it ??

Thanks

Amel NASRI
ST Employee
Posted on September 15, 2015 at 18:19

There is no SDIO in STM32F107VCT6.

SDIO is available in STM32F103 devices. You can check the list of these devices when creating new project in CubeMX based on the MCU selector (Select SDIO in the peripherals list).

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.