2022-08-26 09:23 AM
Hello I'm using SPI to interface my STM32F7 with the SX1262 radio.
I got a weird behavior, I'm using a GPIO to toggle the NSS pin. But sometimes it toggles randomly during the data transfer. You can see on the following screenshot of my logic analyzer:
Here's the code for it:
void WriteBuffer(SPI_HandleTypeDef hspiX)
{
while(HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_13) == 1)
{
}
uint16_t WriteBufferSize = 6;
uint8_t WriteBufferCmd[] = {0x0E, 0x00, 0x33, 0x65, 0x67, 0x67}; // !ACC
//uint8_t WriteBufferAnswer[6];
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspiX,(uint8_t *)WriteBufferCmd,WriteBufferSize,100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
}
Here's the SPI setup:
Solved! Go to Solution.
2022-08-26 10:54 AM
If you have flying wires or a long ribbon cable, this may be result of inadequate ground/return arrangement and/or crostallk.
If this is the case, the remedy is short cables and individual ground/return for each signal. You can try to work around this by increasing the NSS pin's drive by its GPIO_OSPEEDR setting, and decrease other pins' drive.
LA may not be the most adequate tool for this kind of problems.
JW
2022-08-26 10:54 AM
If you have flying wires or a long ribbon cable, this may be result of inadequate ground/return arrangement and/or crostallk.
If this is the case, the remedy is short cables and individual ground/return for each signal. You can try to work around this by increasing the NSS pin's drive by its GPIO_OSPEEDR setting, and decrease other pins' drive.
LA may not be the most adequate tool for this kind of problems.
JW
2022-08-26 11:40 PM
Measure NSS pin by oscilloscope.
2022-08-27 12:28 AM
I suspect other code write other pin of same port, or memory pointer wrong writing. Try the debug watchpoint on the gpio out and bssr or moder register.
2022-08-27 06:02 AM
HAL_SPI_Transmit() is supposed to make sure the transmit completes, ie Tx FIFO empty, not busy, RX FIFO empty.
Not sure why this pin would glitch,would have to be a direct connection with something else or some other code. Anything in an interrupt or callback?
Any error or status returned by the commands?
2022-08-28 09:47 AM
It was a wiring problem after all!
Thank you for the help