Tiny 2040 - a tiny RP2040 stamp
Posted: Sat Mar 13, 2021 1:56 pm
Nice stamp:
https://www.youtube.com/watch?v=KmEyrOTYYCA
https://www.youtube.com/watch?v=KmEyrOTYYCA
Everything relating to using STM32 boards with the Arduino IDE and alternatives
https://www.stm32duino.com/
So ...ag123 wrote: Mon May 17, 2021 9:29 am someone is pretty quick
https://github.com/earlephilhower/arduino-pico
oh and the original arduino isn't too far behind
https://github.com/arduino/ArduinoCore- ... /tag/2.0.0
https://www.tomshardware.com/news/raspb ... o-official
Code: Select all
// https://forum.arduino.cc/t/multicore-on-raspberry-pi-pico/858908/8
/*
From (https://arduino-pico.readthedocs.io/en/latest/multicore.html)
By adding a setup1() and loop1() function to your sketch you can make use of the second core.
Anything called from within the setup1() or loop1() routines will execute on the second core.
Functions:
1) Pausing Cores
- void rp2040.idleOtherCore();
- void rp2040.resumeOtherCore();
2) Communicating Between Cores
- void rp2040.fifo.push(uint32_t);
- bool rp2040.fifo.push_nb(uint32_t);
- bool rp2040.fifo.push_nb(uint32_t);
- bool rp2040.fifo.pop_nb(uint32_t *dest);
- int rp2040.fifo.available();
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#define FLAG_VALUE 0xDEADBEEF
void heartBeatPrint(bool isCore0 = true) {
static int num = 1;
Serial.print(isCore0 ? F("C0") : F("C1"));
if (num == 40) {
Serial.println();
num = 1;
} else if (num++ % 10 == 0) {
Serial.print(F(" "));
}
}
void check_status(bool isCore0 = true) {
static unsigned long checkstatus_timeout = 0;
#define STATUS_CHECK_INTERVAL 10000L
// Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) {
heartBeatPrint(isCore0);
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}
//////////////////////////////////////////////
// Running on Core0
void setup() {
rp2040.idleOtherCore();
Serial.begin(115200);
while (!Serial)
;
Serial.print("\nStart RPI_Pico_Multicore Core0 on ");
Serial.println("BOARD_NAME");
rp2040.resumeOtherCore();
uint32_t g = rp2040.fifo.pop();
rp2040.idleOtherCore();
Serial.print("C0: rp2040_fifo_pop g = 0x");
Serial.println(g, HEX);
if (g == FLAG_VALUE) {
rp2040.fifo.push(FLAG_VALUE);
Serial.println("Core0 OK!");
} else
Serial.println("Core0 not OK!");
rp2040.resumeOtherCore();
}
void loop() {
check_status(true);
}
//////////////////////////////////////////////
// Running on Core1
void core1_entry() {
rp2040.fifo.push(FLAG_VALUE);
uint32_t g = rp2040.fifo.pop();
rp2040.idleOtherCore();
Serial.print("C1: rp2040_fifo_pop g = 0x");
Serial.println(g, HEX);
if (g == FLAG_VALUE)
Serial.println("Core1 OK!");
else
Serial.println("Core1 not OK!");
rp2040.resumeOtherCore();
}
void setup1() {
rp2040.idleOtherCore();
Serial.begin(115200);
while (!Serial)
;
Serial.print("Start RPI_Pico_Multicore Core1 on ");
Serial.println("BOARD_NAME");
rp2040.resumeOtherCore();
core1_entry();
}
void loop1() {
check_status(false);
}
Personal note: On my 4-core i7 6820HQ with 8G RAM,Sketch uses 56928 bytes (2%) of program storage space. Maximum is 2093056 bytes.
Global variables use 12128 bytes (4%) of dynamic memory, leaving 250016 bytes for local variables. Maximum is 262144 bytes.
--------------------------
Compilation complete.
Waiting for upload port...
No upload port found, using COM4 as fallback
"C:\Users\Ray\AppData\Local\Arduino15\packages\rp2040\tools\pqt-python3\1.0.1-base-3a57aed/python3" "C:\Users\Ray\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.4.0/tools/uf2conv.py" --serial "COM4" --family RP2040 --deploy "C:\Users\Ray\AppData\Local\Temp\arduino-sketch-68FFB3D64767CCF49049EAEA9C386380/multicore_test_2.ino.uf2"
Resetting COM4
Converting to uf2, output size: 128000, start address: 0x2000
Flashing D: (RPI-RP2)
Wrote 128000 bytes to D:/NEW.UF2
--------------------------
upload complete.
New Line
115200 baud
Start RPI_Pico_Multicore Core0 on BOARD_NAME
Start RPI_Pico_Multicore Core1 on BOARD_NAME
C0: rp2040_fifo_pop g = 0xDEADBEEF
Core0 OK!
C1: rp2040_fifo_pop g = 0xDEADBEEF
Core1 OK!
C1C0C1C0C0C1C1C0C0C1
viewtopic.php?p=6586#p6586if arduino-cli compile is run with --only-compilation-database ends in error, compile_commands.json is not generated