More information on Problem 2....
The following program makes this obvious even if it's subtil in this case. ('result' is here just to have the CPU doing something... 'cpt' is the only important information.
When powered directly cpt has a very stable value between 401378 and 401380.
When powered through Vin : cpt shows up around 401285...
A very strange thing, when powered through Vin, with a USB cable plugged in the maple mini but not plugged on the other side. Touching the metal part on the unplugged side make the cpt value changing obviously. I saw value down to 350.000 for a short time.
Any idea ???
Any explaination ?
#include "wirish.h"
#include "libmaple.h"
#include "LiquidCrystal.h"
LiquidCrystal lcd(2,8,3,4,5,6,7, 27,26,25, 22);
long test[2048];
void setup() {
lcd.begin(20, 4);
lcd.setCursor(0,0);
lcd.print("Test Perf");
lcd.setCursor(0,1);
lcd.print("--> : ");
lcd.setCursor(0,2);
lcd.print("res : ");
lcd.setCursor(0,3);
lcd.print("cpt : ");
for (int k=0; k<2048; k++) {
test[k] = random(1000);
}
Serial3.begin(31250);
}
long getValueFrom3(long l) {
return test[(l+512)%1024];
}
long getValueFrom2(long l) {
return test[(l+43)%2048] + getValueFrom3(l);
}
long getValueFrom(long l) {
return test[l%2048] + getValueFrom2(l);
}
int iter = 0;
void loop() {
iter++;
unsigned int t = millis();
long cpt = 0;
long result = 0;
while ((millis() - t) < 1024) {
result += getValueFrom(cpt);
cpt ++;
if (Serial3.available() && Serial1.available() && Serial2.available()) {
result ++;
}
}
lcd.setCursor(7,1);
lcd.print(iter);
lcd.setCursor(7,2);
lcd.print(result);
lcd.setCursor(7,3);
lcd.print(cpt);
}
// Force init to be called *first*, i.e. before static object allocation.
// Otherwise, statically allocated object that need libmaple may fail.
__attribute__(( constructor )) void premain() {
init();
}
int main(void)
{
setup();
while (1) {
loop();
}
return 0;
}
Update : sample code modified