cancel
Showing results for 
Search instead for 
Did you mean: 

Best/easiest way to share data between cores in STM32H745

RMcCa
Senior II

I am working with a dual core H7 for the first time and and very confused about how to share data between the two cores. I would like to use the M4 as a slave/background processor for the M7 where the M7 can alert the M4 when there is new data to process and then the M4 signals back when finished.

I can see how to use a semaphore to signal back and forth to synchronize the reading and writing - that part is fairly clear, but what is the best way to declare & use two common buffers? I tried adding the resource manager to both cores in MX-Cube, but it is incomplete and tries to include header files to doesn't exist anywhere in the repository and I couldn't find any useful documentation about the resource manager on the web.

I tried doing something simple and created shared.c & shared.h in the Common directory that contain just the variable declaration for the buffers and then added #include "shared.h" to both main.c, similar to how global variables can be shared between .c files in a single project.. The code compiles and the compiler or linker don't complain when I alter one the variables declared in shared.c in either main.c. Does that mean it might work? If so, then all I'll need to do is add is the semaphore interrupts for both cores.

16 REPLIES 16

Hi

Can you please explain more details? I'm new to dual core MCU. I'm trying to access ADC using M4 core and transfer the data to M7 and print it using USB.

Thank you !

EOzde.1
Associate III

I used Majerle's example to share data between cores. But it does not fast enough to share huge data. I hope there will be more examples about that topic in the feature.

Hi @TSimo.1​ 

could you give me code (project) that released communication between cores ?

I use your fragments, but , may be, i have get some mistakes, when inserteted it to my main file of my project.

I want to send data from M7 to M4

M7 is a master and send to slave M4 data, that data i want to get in M4 core.

Could you give your project?

Best regards.

TSimo.1
Associate II

Hi AAnt.1,

Sorry, I do not have a project using this code that I can give you. However, what I did is very simple. You only need the first code fragment.

I created two 256 byte buffers (one for each direction) and two status bytes (one for each direction. Then I created a pointer to these. You use these just as you would any other buffer, except that they are shared between both cores instead of just one core.

All of the other code is what I used to test the buffers and confirm that they work. You can write your own code that uses these buffers.

Best regards,

@TSimo.1​ 

may be you have main files from M4 and M7 cores ?

I will see what must to be in each core.

Adailton Júnior
Associate II

I edited a little TSimo.1's code and put it in a repository.

https://github.com/adailtonjn68/STM32H7xx_inter-core_data_share