Skip to main content
Madhan
Associate II
April 28, 2020
Question

STM32H745 Inter core data transfer

  • April 28, 2020
  • 4 replies
  • 1411 views

 have periodic tasks (with period set by timer interrupts) running on both cores and i want to exchange data between cores.

Here is a simple example..

M7-- Does some calculations and generates a variable at 20KHz

M4-- Has to use the above variable for some other calculations running at 10KHz

I don't want either core to have a "blocking wait" for the data generated by the other core.

So how do i achieve the above and ensure that M4 doesn't read "half written data" ? It is alright if the code on M4 does not use the most "up-to-date" instance of the variable generated by M7.

Should we use L1 cache or some other special RAM to achieve this ?

This topic has been closed for replies.

4 replies

berendi
Principal
April 28, 2020

If there is only a single 32-bit variable, you can be assured that all bits are written at once, there is nothing else to do.

If there is more data, arrange it in a struct, and put the structs in a circular buffer. Something like this

struct m7_to_m4 {
 int a;
 double b;
 char c[100];
};
 
struct m7_to_m4 ring_m7_to_m4[RINGSIZE];
struct m7_to_m4 *last_m7_to_m4;

On the M7 (source) side, update last_m7_to_m4 when there is a consistent set of data in the buffer. On the M4 side, copy last_m7_to_m4 to a private variable once before each calculation.

Manage the L1 cache properly. Either disable caching of the DMA buffer including the pointer used for communication, clean (M7-to-M4) or invalidate (M4-to-M7) the buffer area in the data cache (watch out for buggy implementations in libraries and elsewhere).

Madhan
MadhanAuthor
Associate II
April 28, 2020

Hey Berendi, thank you so much for the response. Could you please give me a clear picture on what you have told.

To make things simple and precise, two variable a,b hold random number generated by code executed on M7 and should be made available for code executed by M4 -> M4 uses a,b performs addition and stores in variable add (add=a+B), multiplies and store in mult (mult=a*b) -> add and mult should be sent back to code executed by M7 for further operations.

(the whole process will be in a loop, also data should be prevented from overwrite or half-written).

It would be great if you can share any work done by you on similar problem!

Tesla DeLorean
Guru
April 28, 2020

Perhaps your boss could just hire him to perform the work and get paid for it?

The issue here is buffering and cache coherency on the CM7 side, perhaps read a chapter or two in the TRM on the topic, and look at how to program the MMU and use of SCB_InvalidateDCache_by_Addr() and SCB_CleanDCache_by_Addr()

Want some examples? grep the CubeH7 source trees

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..