AnsweredAssumed Answered

spi problem

Question asked by patel.karan on Jul 6, 2015
Latest reply on Dec 27, 2015 by milosevic.sasa
i am using stm32f030c8t6 device .i communicate with external memory ic on spi bus.i am using stmcube32 and mdk-5.
for testing purpose i read its id using spi.i am using spi2. at first am not able to generate clock for that i spent nearly whole day and last found that hal init function dose not initialize cr1 resister so i manual add this(hspi2.Instance->CR1|=0x00000040;).
now able to get is my function
uint8_t GetSrrialSPINVRAM(SPI_HandleTypeDef *deviceFd,uint8_t *rbuff)
     uint32_t result;
     uint8_t spiBuff[2];
     uint16_t junkbuff[10];
          return 0;
     //while(deviceFd->State !=HAL_SPI_STATE_READY);
     //while((deviceFd->Instance->SR & SPI_FLAG_FRLVL)!=  SPI_FRLVL_EMPTY)
     //     junkbuff[0]=deviceFd->Instance->DR;
          return 0;     
     return 1;
i am expecting reply 0x0681c8a0 but i am getting 0x000681c8 and when read 5 byte got
 0x000681c8a0 .so receiving one extra byte at beginning. after searching some time on net i found that its due to dummy receive while i try to flush rxfifo after tx.but when i try flush instruction random data received every time so please guide me whats wrong

here is command information

  i use pb12 as gpio out put which is connected to ss of external ic and data size is 8 bit .

here is init fun
  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_1EDGE;
  hspi2.Init.NSS = SPI_NSS_SOFT;
  hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLED;
  hspi2.Init.CRCPolynomial = 10;

and source freq is 48mz