How can I share date with the two core?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How can I share date with the two core?

448 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by run on Sun Nov 24 13:31:01 MST 2013
Hi,

I just started with the LPC4330 board, and I am wondering how can I exchange data with the two core?

Robert
标签 (1)
0 项奖励
回复
1 回复

430 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Sun Nov 24 13:48:06 MST 2013
This is easy: [color=#060]You can for instance place the data in the local SRAM.[/color]

I've not tried the event system out yet, but what I'd do if I needed to send data back and forth, would be to write the data I wanted to send to the other core to local SRAM, then issue a "Send Event" instruction.
On the M0 core I would probably use a WFE (Wait For Event) or WFI (Wait For Interrupt) instruction, if it's not busy working on something.

Oh, and make sure you take into account that this system behaves like a multithreaded environment, so you'll need some kind of atomic access to your data, so they will not be corrupted. The easiest way of doing that is to have a variable that is used for sending a pointer from the M4 to the M0. The M4 checks if the pointer value is zero. If it is, it is allowed to write to it. If it's nonzero, it does not change it, but waits. The M0 core looks at the pointer when it has time for it, and when the pointer has been read, it writes a zero to the variable, so the M4 can see that it can write a new value. This system can be used from C without any special semaphore/atomic access.
To send the data from the M0 to the M4, you could do the oposite.

If you want to use semaphores and flags, that's also possible; there are assembly instructions for this, and some libraries have Atomic access functions for high-level languages like C.

[color=#333]Hint: If you want to maximize performance, you could let the M0 handle things that the M4 would do almost as quickly, then when the M0 is done doing those operations on the data, it could tell the M4 to do operations that the M4 is very quick at. For instance: The M0 is very slow at multiplying, but it could do block-additions, subtractions and logic operations quite fast.
So the M0 would just do the additions/subtractions/logic operations, then tell the M4 that the job is done, the M4 would do the multiplications and perhaps hand the data back to the M0 for further addtion/subtraction/logical operations.
-But of course you might need to take CPU-time for both cores into account; of course it depends on the job.[/color]
0 项奖励
回复