2025-09-11 12:04 AM
Hi there,
I am using and STM32F469-disco board and want it to communicate via SPI2 with a Battery Management System. When launching only the BMS task it runs perfectly, the communication is stable and I can read cell voltages and temperatures through SPI2 line.
The thing is that when adding touch gfx task (uncommenting the initialize of the kernel) it runs the BMS task as well as Touch GFX task but the BMS task does not work correctly, it does not communicate with BMS. The same code, same task, but adding Touch GFX task creates a conflict that does not lend the SPI2 communicate with other devices.
In theory, the pins for SPI2 (PB14 and PB15) are free of use. I also tried to disable interruptions when reading BMS in BMS task (__disable_irq()) but does not work neither.
Could someone think of a solution, or testing to know where is the problem?
Thank you very much!
PD: I would say that both Cube and Touch are updated to last version.
2025-09-11 1:28 AM
What debugging have you done to see where your BMS comms are failing?
Have you looked at the SPI with an analyser to see what's happening?
2025-09-11 1:50 AM
I am debugging in Cube IDE and looking into live variables.
Next step is looking with an oscilloscope and protocool analyzer the SPI clock,SS signal and the data itself...
2025-09-11 1:59 AM - edited 2025-09-11 2:03 AM
Try also instrumenting the code; eg, add UART output logs to give real-time visibility of what's going on.
Compare & contrast the working & non-working case.
PS:
When it is working, is the BMS task still under FreeRTOS?
Does the Touch GFX task work?
2025-09-11 2:08 AM
When I try to printf in BMS Task with Touch GFX task running the uc goes to Hard Fault, do not know why but I cannot use printf to debug. I have the io_put_char in Usart 3 and the stack size of BMS task is 1024 for preventing printf limit memory usage. In theory the 2 of them are identical, except of one is running CMSIS v2 and the one that runs correctly is not using any OS...
I will update the forum but do not know how to solve this. I'll try to see SPI line in oscilloscope.
2025-09-11 2:21 AM
@Enekkk wrote:When I try to printf in BMS Task with Touch GFX task running the uc goes to Hard Fault
Does the BMS printf work without TouchGFX?
Maybe there's a fundamental issue there?
What if you don't use printf - just direct UART output?
On debugging Hard Faults:
@Enekkk wrote:the stack size of BMS task is 1024 for preventing printf limit memory usage.
How do you know that's sufficient?
@Enekkk wrote:the one that runs correctly is not using any OS...
So maybe the fundamental issue is to do with the OS?
Try getting the BMS to work alone under FreeRTOS before adding TouchGFX?
Always best to change just one thing at a time ...
2025-09-11 2:27 AM
@Andrew Neil wrote:
@Enekkk wrote:When I try to printf in BMS Task with Touch GFX task running the uc goes to Hard Fault
Does the BMS printf work without TouchGFX?
I am not sure about it..
Maybe there's a fundamental issue there?
What if you don't use printf - just direct UART output?
On debugging Hard Faults:
@Enekkk wrote:the stack size of BMS task is 1024 for preventing printf limit memory usage.
How do you know that's sufficient?
I suppose it, there are not many prints and the variables are uint16 values.
@Enekkk wrote:the one that runs correctly is not using any OS...
So maybe the fundamental issue is to do with the OS?
Try getting the BMS to work alone under FreeRTOS before adding TouchGFX?
I'll try that as well. It is happening something with RTOS.
Always best to change just one thing at a time ...
You're right... I made so many tests in too few days that I cannot remember what I have tested and what not.
Thank you for the support, I will be testing next monday.