Launchpad f28379d dual core with Simulink and custom code

3 ビュー (過去 30 日間)
Vit Cibulka
Vit Cibulka 2020 年 1 月 23 日
回答済み: Vit Cibulka 2020 年 1 月 30 日
Hi,
I am trying to develop a dual-core application on the F28379D Launchpad where CPU1 would run custom code (coded in C via CSS) and CPU2 would run
Simulink-generated code.
I have opened the Simulink-generated code in CSS and there seems to be some IPC communication (via the IPC Lite library) between the CPU's
but it is a bit complicated for me to understand.
What I did so far is that I copied the IPC interrupt handler CPU02toCPU01IPC0IntHandler() into my code for CPU1 to prevent the CPU2 getting stuck at
while (IPCLiteLtoRGetResult(&ulRWord32,IPC_LENGTH_32_BITS, IPC_FLAG31) != STATUS_PASS) {}
but this doesn't help entirely. Depending on the (Simulink) code for CPU2 what usually happens is that in CPU2, the call
runModel = rtmGetErrorStatus(dual_CPU1_M) == (NULL);
evaluates as 0 so the main loop while (runModel){...} doesn't execute.
In some other cases the CPU1 ends up in the "Illegal Operation Trap" ILLEGAL_ISR(void).
I am not sure what is the exact cause for each behaviour, but both are surely caused by the fact that I am ignoring some essential startup communication/setup.
I'd like to ask for directions as to what initial IPC communications have to be made between the two CPU's in order to succesfully run Simulink-generated code for CPU2 alongside custom C code for CPU1.
Some info:
My MATLAB version is 2019b.
I am able to run dual-core applications where both CPU's are either Simulink-generated or coded in CSS.
Thanks in advance.
Vít.
  2 件のコメント
Venkatesh Chilapur
Venkatesh Chilapur 2020 年 1 月 24 日
Hi,
Our suggestion would be to try to work on CPU1 from MATLAB as we would have implemented handshaking between the two cores to get through the initialization to get both cores up and running. When you get custom code on CPU1, this handshaking may miss. When you work on CPU1 and CPU2 from MATLAB there is always the gaurnatee that this setup will work. We have custom code blocks and other techniques to include the user handwritten code in to MATLAB. So on CPU1 you should explore these options to get your handwritten code in to MATLAB.
HTH,
Venkatesh C
Vit Cibulka
Vit Cibulka 2020 年 1 月 24 日
Hi Venkatesh,
I would have done it all via Simulink if it was possible, but it is not unfortunately. That is why I resolved to use this approach.
Could you please tell me what needs to be exchanged during the handshake?
I know that the CPU2 calls some CPU1 functions via IPC in order to setup the pins and peripherals it needs but even if I don't use any pins/peripherals in the CPU2, it still doesn't work.
Vit

サインインしてコメントする。

採用された回答

Vit Cibulka
Vit Cibulka 2020 年 1 月 30 日
I got it finally working.
So for anyone wondering, it itsn't as difficult as I thought.
In order to get custom code for CPU1 working, first generate some random source code for CPU1 from Simulink, then copy the function void initSetGPIOIPC(void) from file c2837xDBoard_Realtime_Support.c, put it in the initialization part of your code (after clearing&disabling interrupts - the function hooks one interrupt to IPC) and then fix all dependencies (mostly some #defines, one interrupt routine and some functions... - all from the same source file).
This approach works for blinking diodes and once you load your CPU1 code into the Launchpad, you can just load the CPU2 code directly from Simulink (ctrl+B) and it "just works".

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEmbedded Coder Supported Hardware についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by