cancel
Showing results for 
Search instead for 
Did you mean: 

I am using an stm32h753 MCU and I want to use an SPI Master to receive data from adc without writing. The ADC sends the data when it is activated with CS signal. My problem is that I receive only FF from the slave Do You have any advice on this?

Angelos1
Associate II

Here is the setup of the SPI: (SPI Clock is checked with the datasheet and it is valid, as well as clock phase and clock polarity. 

 hspi2.Instance = SPI2;

 hspi2.Init.Mode = SPI_MODE_MASTER;

 hspi2.Init.Direction = SPI_DIRECTION_2LINES;

 hspi2.Init.DataSize = SPI_DATASIZE_8BIT;

 hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;

 hspi2.Init.CLKPhase = SPI_PHASE_2EDGE;

 hspi2.Init.NSS = SPI_NSS_SOFT;

 hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

 hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;

 hspi2.Init.TIMode = SPI_TIMODE_DISABLE;

 hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

 hspi2.Init.CRCPolynomial = 0x0;

 hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;

 hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;

 hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;

 hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

 hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

 hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;

 hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;

 hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;

 hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;

 hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 __HAL_RCC_SPI2_CLK_ENABLE();

 __HAL_RCC_GPIOB_CLK_ENABLE();

 /**SPI2 GPIO Configuration

 PB10  ------> SPI2_SCK

 PB14  ------> SPI2_MISO

 PB15  ------> SPI2_MOSI

 */

 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_14|GPIO_PIN_15;

 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

 GPIO_InitStruct.Pull = GPIO_NOPULL;

 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;

 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 /* SPI2 interrupt Init */

 HAL_NVIC_SetPriority(SPI2_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(SPI2_IRQn);

0 REPLIES 0