2017-03-30 07:56 PM
Hi All,
I am new to STM , I have problem in read and write data simultaneously using STM32L476 board. i just created a new project using STMcubeMX and try to read and write simultaneously using HAL_SPI_TransmitReceive_IT , and when i checked on my spi sniffer, spi data is sent byte ,byte ... Here my spi init config
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_HIGH; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_SOFT ; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLE; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi1.Init.CRCPolynomial = 7; hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;if (HAL_SPI_Init(&hspi1) != HAL_OK)
is any missing in my configuration.
Thanks in advance.
2017-04-06 12:46 PM
Hi John,
on Disabling NSSP mode, i am observing spi timeout .
2017-04-06 12:47 PM
Hi David, No Luck still i am seeing the same behaviour.
2017-04-06 04:44 PM
here's how I do spi master using hal
HAL_GPIO_WritePin( GPIOB, SPI2_CS1_Pin, GPIO_PIN_RESET );
status = HAL_SPI_TransmitReceive( &hspi2, (uint8_t *)(&txarray), (uint8_t *)(&rxarray), cnt+1, 5); while( hspi2.State == HAL_SPI_STATE_BUSY ) {};HAL_GPIO_WritePin( GPIOB, SPI2_CS1_Pin, GPIO_PIN_SET );
2017-04-07 12:15 AM
You don't need the while. HAL_SPI_TransmitReceive will spin on the RXNE bit until the data has been shifted out or it hits your 5 ms timeout. It might be a better idea to check status for HAL_TIMEOUT.