Hello dear Saro, thank you for posting to the Renesas community.
Unfortunately, we cannot address the exact issue in your code because it can be derived from different sources. but there's some general advice and best practices when you're dealing with real-time critical systems like this and should process multiple tasks.
As you already know CPU can only do one task at a time, but by utilizing RTOS and interrupt handling and preemption we can make it similar to simultaneous processing. Probably there's some blocking pattern in your application that causes the CPU to be no longer available and you're missing some critical events there.
Before anything, try to utilize the software engineering best practices. like UML diagrams and state machine diagrams, dataflow diagrams, and embedded design patterns, if you're not using them. Designing the code before writing even a line of coding sometimes serves you hundreds of hours.
My recommendation is:
-Create an individual RTOS task as a data acquisition task: here you handle the sensors, Analog parameters, and other process-taking demands. utilize queues and buffers for the data to be processed later on.
-An individual task for getting and processing the data from the U/I interface: make it a high-priority task if it is time-critical.
-An individual Processor task: Process the data, routines, and state machines in your code. here you get data from queues or buffers and don't accumulate or process any input data or time-critical tasks.
-Utilize the DMA, DTC, and ELC unit for offloading the CPU when exchanging data.
-Try not to process data or perform long tasks in interrupt functions.
-Also Make sure you're not manipulating the data from two different tasks simultaneously (using mutex) this synchronization mechanism helps you to wait for some other processes to be done and keeps you away from unknown bugs.
Finally, designing a robust application (Specifically in the medical field) can be challenging without proper software engineering, I strongly recommend taking a step back to get a big picture about the overall task process, and their priorities. design error detection mechanisms for each module and make them more traceable and fault tolerant.
I hope you're not exhausted by the long text, and find that information useful. don't hesitate to share your code, or to ask for help if needed.
Best regards,
Hossein.
If this or any other user's response answers your concern, kindly verify the answer. Thank you!
Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/en-support.renesas.com/.../