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){}}//---------------------------------------------------------------------------// This block declares the thread data for one main application thread. It// defines a thread object, stack (in word-array form), and the entry-point// function used by the application thread.#define APP1_STACK_SIZE (300/sizeof(K_WORD))staticThreadclApp1Thread;staticK_WORDawApp1Stack[APP1_STACK_SIZE];staticvoidApp1Main(void*unused_);//---------------------------------------------------------------------------// This block declares the thread data for one main application thread. It// defines a thread object, stack (in word-array form), and the entry-point// function used by the application thread.#define APP2_STACK_SIZE (300/sizeof(K_WORD))staticThreadclApp2Thread;staticK_WORDawApp2Stack[APP2_STACK_SIZE];staticvoidApp2Main(void*unused_);#define APP3_STACK_SIZE (300/sizeof(K_WORD))staticThreadclApp3Thread;staticK_WORDawApp3Stack[APP3_STACK_SIZE];staticvoidApp3Main(void*unused_);#define APP4_STACK_SIZE (300/sizeof(K_WORD))staticThreadclApp4Thread;staticK_WORDawApp4Stack[APP4_STACK_SIZE];staticvoidApp4Main(void*unused_);//---------------------------------------------------------------------------// This is the semaphore that we'll use to synchronize two threads in this// demo applicationstaticSemaphoreclMySem;voidsetup(){// 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's work product.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();// Initialize a binary semaphore (maximum value of one, initial value of// zero)clMySem.Init(0,1);/// clMySem.Post();}voidloop(){// put your main code here, to run repeatedly:Kernel::Start();}//---------------------------------------------------------------------------voidApp1Main(void*unused_){volatileuint32_tu32Counter=0;while(1){u32Counter++;// Wait until the semaphore is posted from the other threadif(u32Counter==1000000){u32Counter=0;Serial.print("Wait1...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();// Producer thread has finished doing its work -- do something to// consume its output. Once again - a contrived example, but we// can imagine that printing out the message is "consuming" the output// from the other thread.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){// Do some work. Once the work is complete, post the semaphore. This// will cause the other thread to wake up and then take some action.// It's a bit contrived, but imagine that the results of this process// are necessary to drive the work done by that other thread.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++;// Wait until the semaphore is posted from the other threadif(u32Counter==1000000){u32Counter=0;Serial.print("Wait3...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();// Producer thread has finished doing its work -- do something to// consume its output. Once again - a contrived example, but we// can imagine that printing out the message is "consuming" the output// from the other thread.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++;// Wait until the semaphore is posted from the other threadif(u32Counter==500000){u32Counter=0;Serial.print("Wait4...");Serial.print(millis());Serial.print("\r\n");clMySem.Pend();// Producer thread has finished doing its work -- do something to// consume its output. Once again - a contrived example, but we// can imagine that printing out the message is "consuming" the output// from the other thread.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.