Question
Nucelo L053r8 SPI Comminucation issue
Posted on April 21, 2016 at 14:51
Heloo,
I Get some Randon Value when i call for data receive. I kindly request you to provide me soultion for my code.SPI config in Mainis declared as :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_2EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLE; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi1.Init.CRCPolynomial = 7; HAL_SPI_Init(&hspi1);}I am trying to receive and transmit value . Is this the way you transmit and receive a value using SPI communication.void ADS1220SendByte(uint8_t Byte){ uint8_t *dummy; /* Call SPI read generic function */ if(HAL_SPI_Transmit(&hspi1, (uint *)Byte, 1,5000) != HAL_OK) { set_ERROR(); } // if(HAL_SPI_Receive(&hspi1, dummy, 1,5000) != HAL_OK)// {// set_ERROR();// } }unsigned char ADS1220ReceiveByte(void){ unsigned char *Result; /* Call SPI read generic function */// if(HAL_SPI_Transmit(&hspi1, (uint8_t *)0xFF, 1,5000) != HAL_OK)// {// set_ERROR();// } if(HAL_SPI_Receive(&hspi1, Result, 1, 5000) != HAL_OK) { set_ERROR(); } return *Result;} #stm32l053 #stm32f4 #nucleo #nucleo #discovery #spi #spi #!stm32 #device