cancel
Showing results for 
Search instead for 
Did you mean: 

problem with SPI daisy chain

mete
Senior

Hello,

I am using IHM02A1 expansion board (on top of L073RZ), which has two L6470 connected in a daisy chain configuration. I cannot receive any data from the devices. What do you think the reason can be ?

Below is the bus status of a reset and get param for register ACC (0x5) since its default value is not 0:

0693W000006FZgkQAG.png 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @mete​ ,

I confirm that the device must be supplied through VS main power supply and the VREG voltage is internally generated starting from VS.

The VDD pin voltage sets only the logic output pin voltage range, is not sufficient to operate the SPI.

Let me know if we can consider solved the problem 😉

View solution in original post

6 REPLIES 6
Cristiana SCARAMEL
ST Employee

Hello @mete​,

did you check the SPI lines solder bridges configuration?

In the user manual UM1964 you can find (at page 11) how the SPI lines are mapped on the ST morpho and Arduino connectors.

The NUCLEO-L073RZ is not supported by the X-CUBE-SPN2 software package, are you using a custom firmware?

Please check and let me know, so I try to help you.

Hello @Cristiana SCARAMEL​ ,

Yes I think so, I actually more than triple checked the connections. I think 072RB and 073RZ is same in terms of the pins, and I also checked through Arduino naming too, so actually the default solder bridges should be fine, so I did not change anything on the board.

I am not using the SPN2 package other than looking at it for reference. So basically this is what I am doing:

  • disable/assert low nRST, wait 5ms
  • I also do an empty HAL_SPI_TransmitReceive here, because I realized SCL stays low even if SPI is configured as CPOL High before the first transfer so I thought maybe it can be a problem. After this SCL stays high.
  • enable/assert high nRST, wait 5ms
  • send SPI reset command (this is on the output above)
  • send SPI get param for ACC (this is on the output above)

While sending SPI reset and get param, I wait at least 1us after asserting nCS low and high.

I copy below the SPI and GPIO configs for you to look at, esp. GPIO config is not something I am 100% sure. (sysclk is 32MHz, I am using /32 for SPI).

static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 
  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOH_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
 
  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(L6470_nCS_GPIO_Port, L6470_nCS_Pin, GPIO_PIN_SET);
 
  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
 
  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(L6470_nSTBY_nRST_GPIO_Port, L6470_nSTBY_nRST_Pin, GPIO_PIN_SET);
 
  /*Configure GPIO pin : B1_Pin */
  GPIO_InitStruct.Pin = B1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
 
  /*Configure GPIO pins : L6470_nBUSY_SYNC_Pin L6470_nFLAG_Pin */
  GPIO_InitStruct.Pin = L6470_nBUSY_SYNC_Pin|L6470_nFLAG_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
  /*Configure GPIO pins : USART_TX_Pin USART_RX_Pin */
  GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF4_USART2;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
  /*Configure GPIO pin : L6470_nCS_Pin */
  GPIO_InitStruct.Pin = L6470_nCS_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(L6470_nCS_GPIO_Port, &GPIO_InitStruct);
 
  /*Configure GPIO pin : LD2_Pin */
  GPIO_InitStruct.Pin = LD2_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
 
  /*Configure GPIO pin : L6470_nSTBY_nRST_Pin */
  GPIO_InitStruct.Pin = L6470_nSTBY_nRST_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(L6470_nSTBY_nRST_GPIO_Port, &GPIO_InitStruct);
 
  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
 
  HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
 
}
static void MX_SPI1_Init(void)
{
 
  /* USER CODE BEGIN SPI1_Init 0 */
 
  /* USER CODE END SPI1_Init 0 */
 
  /* USER CODE BEGIN SPI1_Init 1 */
 
  /* USER CODE END SPI1_Init 1 */
  /* SPI1 parameter configuration*/
  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_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 7;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */
 
  /* USER CODE END SPI1_Init 2 */
 
}

Meanwhile I found a 072RB and wanted to try the SPN2 firmware. I programmed the binary and I run it without connecting any motor and I was still seeing 0s (I didnt change the probe locations) and on the UART output it was also all 0s. Then I thought maybe I need to connect VS, I did and I see both on the oscilloscope and on the UART output some activity. It seems VS needs to be connected and I missed that in the documents.

Mete

I should have read the datasheet carefully, so I think it is particularly about this:

"During power-up, the device is under reset (all logic IOs disabled and power bridges in high

impedance state) until the following conditions are satisfied:

- VS is greater than VSthOn

- VREG is greater than VREGth = 2.8 V typical

- Internal oscillator is operative."

which are naturally not satisfied if VS is not applied.

Hello @mete​ ,

I confirm that the device must be supplied through VS main power supply and the VREG voltage is internally generated starting from VS.

The VDD pin voltage sets only the logic output pin voltage range, is not sufficient to operate the SPI.

Let me know if we can consider solved the problem 😉

Hello @Cristiana SCARAMEL​,

Good to know "The VDD pin voltage sets only the logic output pin voltage range, is not sufficient to operate the SPI.", I was not sure about that.

Yes it is solved, I am working with it without a problem.