cancel
Showing results for 
Search instead for 
Did you mean: 

STPM33 spi read issue

Dev_Oza
Associate

I am using STM32 H563 Nucleo board to read the configurational register (address = 0x24) of STPM33 evaluation board using SPI protocol but while debugging the code i am getting random values on each transmission.

 

Firstly i am transmitting an bytes {0x24,0xFF,0xFF,0xFF,0x99} to set the read pointer to address 0x24, and then again transmitting bytes {0xFF,0xFF,0xFF,0xFF,0xDE} to read the data of register. After each transmission i am receiving random values.

 

Below are the SPI settings

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_2EDGE;

hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;

hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi1.Init.CRCPolynomial = 0x7;

hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;

hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;

hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;

hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;

hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;

hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;

hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;

hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;

hspi1.Init.ReadyMasterManagement = SPI_RDY_MASTER_MANAGEMENT_INTERNALLY;

hspi1.Init.ReadyPolarity = SPI_RDY_POLARITY_HIGH;

 

Below are the images of data received after each transaction:

Dev_Oza_0-1712052899008.pngDev_Oza_1-1712052912298.png

Dev_Oza_2-1712052924621.pngDev_Oza_3-1712052938852.png

Dev_Oza_4-1712052973963.png

Also i am attaching the main.c file for further reference.

0 REPLIES 0