Question
NUCLEO-L4P5ZG to NRF52-DK SPI not working, but works with NUCLEO-F446RE.
Hi,
I am trying to use Nucleo-l4p5 as SPI Master and NRF52 as slave.
Issue : nrf is reading wrong and partial data and when I am connecting GND of both boards, it stops working.
Solutions tried so far:
- I have tried the same code with Nculeo-F446RE and NRF52-DK:
- It is sending wrong and partial data, GND not common between boards.
- It works as expected with GND common.
- I have tried Nucleo-l4p5(Master) to Nucleo-l4p5(Slave), with GND connected. It works as expected.
- I have tried powering One board with another, but again freezing issue.
- I have tried lowering the master clock.
// ST master code
while (1)
{
if (count%2 == 1)
{
memset(buffer1, buffer1, 6);
HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_RESET);
HAL_Delay(10);
HAL_SPI_Transmit(&hspi3, &buffer1, 6, 100);
HAL_Delay(10);
HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_SET);
}
else
{
memset(buffer1, buffer1, 6);
HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_RESET);
HAL_Delay(10);
HAL_SPI_Transmit(&hspi3, &buffer1, 6, 100);
HAL_Delay(10);
HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_SET);
}
count++;
HAL_Delay(1000);Clock is configured for PCLK1(60) and PCLK2(120)
This is the configuration:
static void MX_SPI3_Init(void)
{
/* USER CODE BEGIN SPI3_Init 0 */
/* USER CODE END SPI3_Init 0 */
/* USER CODE BEGIN SPI3_Init 1 */
/* USER CODE END SPI3_Init 1 */
/* SPI3 parameter configuration*/
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi3.Init.NSS = SPI_NSS_SOFT;
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 7;
hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI3_Init 2 */
/* USER CODE END SPI3_Init 2 */
}