Page 1 of 1

SIPEED MAIX/K210: Access Multi-Core CPU functions in Arduino?

Posted: Tue Oct 08, 2019 3:23 am
by crmann25
Is there any information regarding the K210 multi-core feature and Arduino? Is this even supported?

Re: SIPEED MAIX/K210: Access Multi-Core CPU functions in Arduino?

Posted: Sun Dec 15, 2019 5:12 pm
by uli649
suggestion:

2 Tabs in Arduino IDE

Main Tab: (Core0 code)

Code: Select all

#include <entry.h>

const uint8_t led = LED_RED;

void setup() 
{
  Serial.begin(9600);
  Serial.print("Start Core: "); Serial.println(current_coreid());
  pinMode(led,OUTPUT);
  register_core1(main1 , NULL ); 
}

void loop() 
{
  const unsigned long interval = 333;
  static uint64_t merker = 0;
  static bool ledStatus = false;
  if(millis() - merker > interval)
  {
    merker+=interval;
    ledStatus = !ledStatus;
    digitalWrite(led,ledStatus); 
  }
}


Second Tab: (Core1 code)

Code: Select all

const uint8_t led1 = LED_BLUE;

void setup1()
{
  Serial.print("Start Core: "); Serial.println(current_coreid());
  pinMode(led1,OUTPUT);
}


void loop1()
{
  const unsigned long interval = 1000;
  static uint64_t merker = 0;

  static bool ledStatus = false;
  if(millis() - merker > interval)
  {
    merker+=interval;
    ledStatus = !ledStatus;
    digitalWrite(led1,ledStatus);
  }
}

int main1(void *parameter)
{
  setup1();
  while(1)
  {
    loop1();
  }
}
It is blinking with two led.


Be careful with concurrent access to resources.
Example: the serial outputs of both cores mix