Skip to main content
mete
Senior
December 13, 2020
Solved

problem with SPI daisy chain

  • December 13, 2020
  • 1 reply
  • 4013 views

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 

This topic has been closed for replies.
Best answer by Cristiana SCARAMEL

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

1 reply

Cristiana SCARAMEL
Technical Moderator
December 14, 2020

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.

"If you feel a post has answered your question, please click ""Accept as Solution"""
mete
meteAuthor
Senior
December 14, 2020

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 */
 
}