cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck in initial SPI comms SpiritManagementIdentificationRFBoard

PaoloValentino
Associate II

Hi everyone,

I'm currently porting SPIRIT1 example in order to carry out the basic implementation in my on board.

I've configured SPI config this way:

void RadioSpiInit(void)
{
	  /* SPI1 parameter configuration*/
	pSpiHandle.Instance = SPI1;
	pSpiHandle.Init.Mode = SPI_MODE_MASTER;
	pSpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
	pSpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
	pSpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
	pSpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
	pSpiHandle.Init.NSS = SPI_NSS_SOFT;
	pSpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
	pSpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
	pSpiHandle.Init.TIMode = SPI_TIMODE_DISABLE;
	pSpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
	pSpiHandle.Init.CRCPolynomial = 7;
	  if (HAL_SPI_Init(&pSpiHandle) != HAL_OK)
	  {
	    Error_Handler();
	  }
}

and GPIOs:

 /*Configure RF ShutDown Pin*/
  GPIO_InitStruct.Pin = SDN_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
 
  /*Configure RF SPIRIT1_GPIO3_Pin*/
  GPIO_InitStruct.Pin = SPIRIT1_GPIO3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
 
  /*Configure RF SPI_CS_Pin*/
 
  GPIO_InitStruct.Pin = SPI_CS_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(SPI_CS_GPIO_Port, &GPIO_InitStruct);
    //SPI1_NSS
    GPIO_InitStruct.Pin = GPIO_PIN_4;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    //SPI1_SCK
    GPIO_InitStruct.Pin = GPIO_PIN_3;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
    //SPI1_MOSI & SPI1_MISO
    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

The code is running as it is spected, but when it is called SpiritManagementIdentificationRFBoard() function it is stuck in SpiritRefreshStatus().

Seems there is SPI comms because MCU save READY STATE, XON 1 and RX_FIFO_EMPTY flag set. But:

while(!((((uint8_t*)&g_xStatus)[0])==tempRegValue[1] && 

     (((uint8_t*)&g_xStatus)[1]&0x0F)==tempRegValue[0]))

It is never true.

Any suggestion?

Thanks in advance

1 REPLY 1
PaoloValentino
Associate II

Hardware SPI problems, solved with new PCB design.