Yes, Mark3 does support Arduino IDE -- the Arduino specific .zip release can be imported directly as a library. Note that support at this time is limited to AVR atmega328p and atmega1280/2560-based boards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tesing for some days.
It's very depended on script coding.
#include<mark3.h>unsignedlongtimer;intsta=0;/*#if !KERNEL_USE_IDLE_FUNC# error "This demo requires KERNEL_USE_IDLE_FUNC"#endif*/extern"C"{void__cxa_pure_virtual(void){}}//---------------------------------------------------------------------------//Thisblockdeclaresthethreaddataforonemainapplicationthread.It//definesathreadobject,stack(inword-arrayform),andtheentry-point//functionusedbytheapplicationthread.#defineAPP1_STACK_SIZE(300/sizeof(K_WORD))staticThreadclApp1Thread;staticK_WORDawApp1Stack[APP1_STACK_SIZE];staticvoidApp1Main(void*unused_);//---------------------------------------------------------------------------//Thisblockdeclaresthethreaddataforonemainapplicationthread.It//definesathreadobject,stack(inword-arrayform),andtheentry-point//functionusedbytheapplicationthread.#defineAPP2_STACK_SIZE(300/sizeof(K_WORD))staticThreadclApp2Thread;staticK_WORDawApp2Stack[APP2_STACK_SIZE];staticvoidApp2Main(void*unused_);#defineAPP3_STACK_SIZE(300/sizeof(K_WORD))staticThreadclApp3Thread;staticK_WORDawApp3Stack[APP3_STACK_SIZE];staticvoidApp3Main(void*unused_);#defineAPP4_STACK_SIZE(300/sizeof(K_WORD))staticThreadclApp4Thread;staticK_WORDawApp4Stack[APP4_STACK_SIZE];staticvoidApp4Main(void*unused_);//---------------------------------------------------------------------------//Thisisthesemaphorethatwe'll use to synchronize two threads in this// demo applicationstatic Semaphore clMySem;void setup() { // put your setup code here, to run once: // start serial port at 9600 bps: Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } pinMode(13,OUTPUT); Serial.print("Application start!...............\r\n"); // See the annotations in previous labs for details on init. Kernel::Init(); // In this example we create two threads to illustrate the use of a // binary semaphore as a synchronization method between two threads. // Thread 1 is a "consumer" thread -- It waits, blocked on the semaphore // until thread 2 is done doing some work. Once the semaphore is posted, // the thread is unblocked, and does some work. // Thread 2 is thus the "producer" thread -- It does work, and once that // work is done, the semaphore is posted to indicate that the other thread // can use the producer'sworkproduct.clApp1Thread.Init(awApp1Stack,APP1_STACK_SIZE,1,App1Main,0);clApp2Thread.Init(awApp2Stack,APP2_STACK_SIZE,1,App2Main,0);clApp3Thread.Init(awApp3Stack,APP3_STACK_SIZE,2,App3Main,0);clApp4Thread.Init(awApp4Stack,APP4_STACK_SIZE,1,App4Main,0);clApp1Thread.Start();clApp2Thread.Start();clApp3Thread.Start();clApp4Thread.Start();//Initializeabinarysemaphore(maximumvalueofone,initialvalueof//zero)clMySem.Init(0,1);///clMySem.Post();}voidloop(){//putyourmaincodehere,torunrepeatedly:Kernel::Start();}//---------------------------------------------------------------------------voidApp1Main(void*unused_){volatileuint32_tu32Counter=0;while(1){u32Counter++;//Waituntilthesemaphoreispostedfromtheotherthreadif(u32Counter==1000000){u32Counter=0;Serial.print("Wait1...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();//Producerthreadhasfinisheddoingitswork-- do something to//consumeitsoutput.Onceagain-acontrivedexample,butwe//canimaginethatprintingoutthemessageis"consuming"theoutput//fromtheotherthread.Serial.print("Triggered!1\r\n");Serial.print("Posted1...");Serial.print(millis());Serial.print("\r\n");digitalWrite(13,LOW);clMySem.Post();}}}//---------------------------------------------------------------------------voidApp2Main(void*unused_){volatileuint32_tu32Counter=0;while(1){//Dosomework.Oncetheworkiscomplete,postthesemaphore.This//willcausetheotherthreadtowakeupandthentakesomeaction.//It'sabitcontrived,butimaginethattheresultsofthisprocess//arenecessarytodrivetheworkdonebythatotherthread.u32Counter++;if(u32Counter==2000000){u32Counter=0;Serial.print("Posted2...");Serial.print(millis());Serial.print("\r\n");digitalWrite(13,LOW);clMySem.Post();}}}//---------------------------------------------------------------------------voidApp3Main(void*unused_){volatileuint32_tu32Counter=0;while(1){u32Counter++;//Waituntilthesemaphoreispostedfromtheotherthreadif(u32Counter==1000000){u32Counter=0;Serial.print("Wait3...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();//Producerthreadhasfinisheddoingitswork-- do something to//consumeitsoutput.Onceagain-acontrivedexample,butwe//canimaginethatprintingoutthemessageis"consuming"theoutput//fromtheotherthread.Serial.print("Triggered!3\r\n");Serial.print("Posted3...");Serial.print(millis());Serial.print("\r\n");digitalWrite(13,HIGH);clMySem.Post();}}}//---------------------------------------------------------------------------voidApp4Main(void*unused_){volatileuint32_tu32Counter=0;while(1){u32Counter++;//Waituntilthesemaphoreispostedfromtheotherthreadif(u32Counter==500000){u32Counter=0;Serial.print("Wait4...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();//Producerthreadhasfinisheddoingitswork-- do something to//consumeitsoutput.Onceagain-acontrivedexample,butwe//canimaginethatprintingoutthemessageis"consuming"theoutput//fromtheotherthread.Serial.print("Triggered!4...");Serial.print(millis());Serial.print("\r\n");digitalWrite(13,HIGH);}}}
if I comment some code,for example,digitalWrite or pinMode. It will loop on setup()
or hang where NOTTHING happened...
Older version (R1) have no problem with those issues.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
From those symptoms sound like stack overflow. Newer releases such as R5, when compiled with the KERNEL_USE_IDLE_FUNC flag set (as is the case in the default Arduino version of mark3cfg.h) will incur a stack size penalty relative to older releases. Try increasing the stack size, or disabling the KERNEL_USE_IDLE_FUNC feature and adding a dedicated idle thread.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does it support Arduino IDE?
Or it just supported Atmel Studio and GCC?
Thanks a lot.
Last edit: MOP 2017-03-26
Yes, Mark3 does support Arduino IDE -- the Arduino specific .zip release can be imported directly as a library. Note that support at this time is limited to AVR atmega328p and atmega1280/2560-based boards.
Tesing for some days.
It's very depended on script coding.
if I comment some code,for example,digitalWrite or pinMode. It will loop on setup()
or hang where NOTTHING happened...
Older version (R1) have no problem with those issues.
From those symptoms sound like stack overflow. Newer releases such as R5, when compiled with the KERNEL_USE_IDLE_FUNC flag set (as is the case in the default Arduino version of mark3cfg.h) will incur a stack size penalty relative to older releases. Try increasing the stack size, or disabling the KERNEL_USE_IDLE_FUNC feature and adding a dedicated idle thread.