2 of 2 people found this helpful
A global variable defined in shared-code folder will be compiled as two variables, one for each core. One way you could declare shared memory between two cores is to use pointers and point to a known fixed memory location or region. However it is recommended that you use IPC to implement semaphores/mutexes when sharing resources (including memory) between CPU cores. Please see section 4.1 of this document to get more insight:PSoC® 6 Dual-Core CPU System Design
It is always advisable to use the volatile keyword if you expect the variable content to change outside of the current code context. This will ensure that compiler optimizations are not applied on the said variable. To answer your question about all shared memory being volatile, the answer is a partial yes. It all depends on how you define and use the shared memory: say with the use of pointers, you need not use the volatile keyword.
Well, I can allocate a few bytes of memory dynamically. However I'll still need to pass the pointer to the other core...how would you do this?
And for semaphores/mutexes, I understand that I need to synchronize access to shared variables. However I have no idea how. Could you tell more about this, and how it is implemented in PSoC6 ?
1 of 1 people found this helpful
The draft application note in another thread addresses the shared memory issue. There is an associated code example which I will also publish. Please let me know if these address your needs.