2019-12-13 12:04 AM
I am using an stm32f042k6 - Nucleo Board. I am using SPI and UART in non - blocking mode initialized through Cube-MX. I am trying to interface an RPI through SPI1 and a BMS through USART1.
SPI1 is configured as a Full-Duplex Slave. USART1 is configured to be asynchronous. Global interrupts are enabled for both.
Pinout:
The issue is that as soon as I call
HAL_SPI_Receive_IT();
in the User Code 2 Section, both peripherals stop working.
In SPI, SCLK, NSS and MOSI work fine. The callback functions are triggered fine and the stm reads the incoming data but MISO is always high. As a result the Rpi keeps getting 0xff. UART stops working completely with the RX remaining high.
I have tried using UART in blocking mode along with SPI in interrupt mode as well but the same issue happens. I can't use SPI in blocking mode because data from the Rpi can come at any time.
Note that both peripherals work fine separately be it in Blocking or Non-Blocking mode.
What I have tried so far:
while(HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY);
It never leaves the loop. Rxstate is 34. gstate is 32.
I can't share the code because this is work related. I hope you guys can point me in the right direction to figure this out. I am not sure what to try next? Is this a bug with CubeMX?
Thank you very much.
2022-12-23 07:00 AM
Hello, did you find a solution for your problem ? I am struggling with same problem for 3-4 days and deadline is getting closer. I will be very happy if you share the solution that you applied for your project.