Use of double core in M5stack
-
I tested n program for ESP32 designed for Arduino ( Esp32/Esp32_dobleNucleo/Esp32_dobleNucleo.ino), and modified it to test in my M5stack. But even though it is checked and loaded correctly. At the start of the job the M5stack is reset every 10", cyclicly. Someone can help me. The code is :
#include"M5Stack.h"
bool bandera = true;TaskHandle_t Tarea1;
void loop_tarea1(void * pvParameters)
{
m5.lcd.setCursor(0,70);
m5.Lcd.print("tarea1()");
m5.Lcd.print(xPortGetCoreID());
while (1)
{ M5.Lcd.drawRect(150, 120, 122, 110, YELLOW);
delay(1000);
M5.Lcd.drawRect(150, 120, 122, 110, BLUE);
delay(1000); }
}
void setup(){
M5.begin(); // inicio del M5s LCD
m5.Lcd.setTextSize(2);
m5.lcd.setCursor(0,10);
m5.lcd.print("SETUP =");
m5.Lcd.print(xPortGetCoreID());
xTaskCreatePinnedToCore(loop_tarea1, "Tarea1", 10000, NULL, 0, &Tarea1,0);
}
void loop()
{ if(bandera) {
m5.lcd.setCursor(0,30);
m5.Lcd.print("Loop()=");
m5.Lcd.print(xPortGetCoreID());
bandera = false; }M5.Lcd.drawRect(20,120, 122, 110, BLUE);
delay(400);
M5.Lcd.drawRect(20, 120, 122, 110, YELLOW);
delay(400);
} -
I understood the problem, there is a conflict when using the same resource the LCD. I introduced a delay in the second loop and matched the flashing times and it works correctly. But now my question is, how to use resources or variables with the two LOOPs simultaneously?.
…….
void loop_tarea1(void * pvParameters)
{ delay(250);
m5.lcd.setCursor(0,70)
m5.Lcd.print("tarea1()")
……..; -
I keep studying how to share data between the two loops, I have located the FreeRtos manuals and they are very complex for my level. I have written this code, but with the same result ,when sending data the M5stack will reboot . I'd appreciate some help.
#include"M5Stack.h"
int mensaje;
int mensaje1;
QueueHandle_t queue_1;
void loop_tarea1(void * pvParameters);void setup(){
M5.begin(); // inicio del M5s
queue_1 = xQueueCreate(4, sizeof(int));
if( queue_1 == 0 )
{
m5.Lcd.setTextSize(2);
m5.Lcd.print("no creada la lista");}
xTaskCreatePinnedToCore(loop_tarea1, "Tarea1", 500, NULL, 2, NULL,0);
}void loop_tarea1(void * pvParameters)
{
for( ;; ) {
if (xQueueReceive(queue_1, &mensaje1, portMAX_DELAY) == pdPASS) {
m5.Lcd.setTextSize(5);
m5.Lcd.setCursor(150,0);
m5.Lcd.print(mensaje1);}
}
}void loop()
{ mensaje=0;
if (Serial.available()){
mensaje=Serial.read();
Serial.print(mensaje);
delay(100);
xQueueSend(queue_1, &mensaje, portMAX_DELAY); }
} -
Some set of parameters, and already work the two loops without interference.
#include"M5Stack.h"
int mensaje=0;
int mensaje1;
QueueHandle_t queue_1;
void loop_tarea1(void * pvParameters);void setup(){
M5.begin(); // inicio del M5s
queue_1 = xQueueCreate(1, sizeof(int));
if( queue_1 == 0 )
{
m5.Lcd.setTextSize(2);
m5.Lcd.print("no creada la lista");}
xTaskCreatePinnedToCore(loop_tarea1, "Tarea1",1500, NULL, 1, NULL,0);
}void loop_tarea1(void * pvParameters)
{
for( ;; ) {
if (xQueueReceive(queue_1, &mensaje1, ( TickType_t ) 10) ) {
m5.Lcd.setTextSize(5);
m5.Lcd.setCursor(150,0);
m5.Lcd.print(mensaje1);}
}
}void loop()
{ mensaje=0;
if (Serial.available()){
mensaje=Serial.read();
xQueueSendToFront(queue_1, &mensaje, ( TickType_t ) 10); }
delay(10);
}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login