Skip to main content
February 17, 2022
Question

STM32F215 gets stuck

  • February 17, 2022
  • 3 replies
  • 1528 views

Due to privacy policies I cannot publish my code.

I am creating a datalogger that receives information from CAN IT and USART IT and stores it on a microSD via SPI. With each interruption I get the time from the RTC and I also use the ADC to unmount the microSD when the voltage level drops.

It should be noted that the information I receive from the UART is periodic and of known length: 50 bytes every 98 ms while the information received by CAN has a more random behavior and its flow is very intense because it would be exposed to a CAN network with tens of different messages. The main function doesn't have times, it just waits for the buffers to fill up.

To avoid loss of information due to communication failures, I have implemented the reception of USART with DMA and it receives to IDLE.

My specific problem is that everything works fine for about 1 minute and then the micro gets stuck, I can tell by the blinking of an LED.

If I disable CAN, USART works without problems. If I disable USART, CAN works fine. It is the implementation of both peripherals that causes conflict.

I've tried different things but nothing seems to work:

  • Remove DMA
  • Change Systick for a TIM
  • Modify interrupt priorities in various ways (higher priority CAN, higher priority USART, higher priority DMA, different priority groups, etc).
  •  

I could think that it is a deficiency of the microcontroller in the face of so many interruptions, but I do not understand how at the beginning everything works and after a while it no longer works.

    This topic has been closed for replies.

    3 replies

    Super User
    February 17, 2022

    > then the micro gets stuck

    "gets stuck" is not a good description. Leave a debugger attached and check what's going on. Hard fault? Check error conditions for all API calls. Use SWO tracing. Use some GPIO for monitoring IRQs.. and hook up a logic analyzer and check the real-time behaviour.

    hth

    KnarfB

    Super User
    February 17, 2022

    Where does it get stuck? Debug it, hit pause, and see where the execution is. What does "stuck" mean specifically?

    Unlikely to be a hardware issue with too many interruptions. More likely that your software logic is getting tripped up somewhere. Perhaps due to an overflow or a race condition.

    February 17, 2022

    I mean that I toggle a led each time the write function is going to be executed on the microSD. The microcontroller gets stuck because after that time (1 min approx) the led stops toggling and the execution of the program is interrupted, which also means that the microSD cannot be unmounted and the files get corrupted.

    Super User
    February 17, 2022

    As already said, you might have to really dig deep here to find the root cause in your software.

    KnarfB

    February 17, 2022

    After debugging I realized that I had some problems:

    • A variable did overflow
    • Therefore, when trying to access the buffer in that position, the HardFalt interrupt was executed.

    Thanks!