2023-11-03 11:37 AM - edited 2023-11-06 05:45 AM
I have a f767 SPI1 connected to F411 SPI2. F411 DMA Circular buffers at 64 bytes.
F7 is sending and receiving 32 byte packets at 10Hz
F7 Clock is at 196Mhz, F4 clock is at 100MHz
After a few hundred packets the F4 NDTR dma register for TX is no longer 63 or 31 when Half or full RXTX interrupt occurs, but changes to a different value. This causes my expected F4 TX pkt filler to be out of alignment with the next DMA packet TX location. The RX->ndtr seems to be fine each time.
How do I reset the DMA to realign the NPTR counters.
If I slow down the F7 SPI clock the problem occurs less often.
When we go to PCB the hope is that this will not be a problem.
We need to connect 40 F411 to 4 SPI busses on 1 F7. Running with 32 pkts at 1Khz
static void MX_SPI2_Init(void)
{
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_SLAVE;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_HARD_INPUT;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
}
static void MX_SPI1_Init(void)
{
/* 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_1EDGE;
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;
hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
}
2023-11-06 05:44 AM
Once I stopped using the ST LINK debugger and just use run, the problem has not reappeared in multiple hours of testing and sending over 200,000 32byte packets.
So it appears that the debugger is interfering with DMA.