2021-07-21 03:12 AM
Hello,
I am doing a project in which I have to receive bytes via SPI from a U-Blox GNSS receiver, specifically the NEO-M9N. I am using the STM32F0308 Discovery development board.
For the NEO-M9N to constantly send information, it must receive a continuous SPI clock.
I have tried to implement an SPI communication using block mode and another with interruptions. In both I have obtained the same result, I do not receive data from the GNSS chip.
In the case of interruptions mode, I call the function in 'main' for the first time: HAL_SPI_Receive_IT (& hspi1, spiRxDataBuff, 82).
In the callback function:
void HAL_SPI_RxCpltCallback (SPI_HandleTypeDef * hspi)
{
HAL_UART_Transmit (& huart2, spiRxDataBuff, 82, HAL_MAX_DELAY);
HAL_SPI_Receive_IT (& hspi1, spiRxDataBuff, 82);
}
That way I get to transmit the buffer via UART and call the SPI reception function again so that data is constantly received via SPI (supposedly).
UART works perfectly. Observing the different lines with the oscilloscope, I have observed that the SPI clock is discontinuous. There is a separation between the reception of each buffer. This causes the NEO-M9N to malfunction and not send data over MISO.
Is there a way to create a constant SPI communication where the clock is constant?
Thanks in advance.
2021-07-21 05:04 AM
It doesn't need a constant clock, it needs you to pump data across the interface periodically, send 0xFF dummy bytes until no UBX packets or NMEA sentences are available. Data typically ready once a second, but a TXREADY signal is also available.
It will stop sending data on the interface if the data is not flushed quickly enough, but we're not talking micro seconds. Should be able to restart by sending a polling request.
2021-08-03 01:03 AM
Thanks for your quick response. I'm sorry to take so long to answer because I have been recovering for a few days.
If a constant clock is not needed, why does running HAL_SPI_receive not get anything? What would you change about my code?
Thank you very much in advance