sparkfun / Arduino_Apollo3

Arduino core to support the Apollo3 microcontroller from Ambiq Micro
83 stars 37 forks source link

Arduino functions inconsistent / not working #262

Closed kerryeven closed 3 years ago

kerryeven commented 4 years ago

Platform: Windows 10 19041.450 Arduino 1.8.12 Java 1.8.0_261 Device: Tried Artemis Redboard Nano and Edge2 and no board connected Core location: c/Users/Me/AppData/Local/Arduino15/packages/SparkFun/hardware/apollo3/2.0.0 Arduino Preferences: Arduino_Apollo3 ... package_sparkfun_apollo3_index.json

Description: Have been using Apollo3 Arduino through version 1.0.30. Updated to 2.0 after adding preference above.

Very simple Arduino sketch. Serial works on Edge2 but not Nano, LED_BUILTIN lights on Nano but not Edge 2.

So close to modifying ArduinoBLE example for conrolling LED from phone, but can't get LED to light on Edge2. That would have the same functionality as the old Example8_BLE you guys had.

** Edge2 works great for ArduinoBLE Hello World Example. Nano locks up, possibly due to Serial problem.

Arduino Sketch:

define BAUD 9600 // any number, common choices: 9600, 115200, 230400, 921600

define CONFIG SERIAL_8N1 // a config value from HardwareSerial.h (defaults to SERIAL_8N1)

const PinName ledPinName = LED1; //Works for Nano. Does not work for Edge2 //const pin_size_t ledPinNumber = LED_BUILTIN; //Works for Nano. Does not work for Edge2

void setup() { // put your setup code here, to run once: //Serial.begin(BAUD); //Serial.println("Booting..."); //Program stops after a couple of char's on Nano, works for Edge2 pinMode(ledPinName, OUTPUT); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 digitalWrite(ledPinName, HIGH); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 //pinMode(ledPinNumber, OUTPUT); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 //digitalWrite(ledPinNumber, HIGH); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 //Serial.println("LED should be on"); //Never gets here on Nano, Works for Edge2

}

void loop() { // put your main code here, to run repeatedly:

}

Wenn0101 commented 4 years ago

Thanks for the report! I'll look into this and see what I can find.

kerryeven commented 4 years ago

More info:
Sparkfun SVL uploads but does not allow LED to turn on, while ASB does work at least for Artemis Nano (SVL is still noted as recommended).

delay(...) not working. Only have following in code for Nano in setup. Light turns on but does not turn off. (Used HIGH and LOW as well). pinMode(LED_BUILTIN, OUTPUT); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 digitalWrite(LED_BUILTIN, 1); //LED_BUILTIN works for Nano, not for edge2, tried LED1,LED_RED,LED2 delay(5000); digitalWrite(LED_BUILTIN, 0);

Haven't tried analogWrite for pwm yet or digital write to a pin but????

Also - Ran Mbed Studio- mbed-os-6-example-blinky on nano = Led flashes rapidly a couple of times then stays on. Edge2 - with the same program acts as it should blinking every 500ms without stopping. Something about the target for Nano? Oops: just found out ThisThread::sleep_for() never varies blink rate -> tried 5000, 5s, 5000ms - rate never increased on Edge2.

Error thrown with ArtemisNano: ++ MbedOS Fault Handler ++

FaultType: HardFault

Context: R0: 1 R1: 0 R2: B1D84601 R3: 0 R4: 0 R5: 0 R6: 0 R7: 0 R8: 0 R9: 0 R10: 0 R11: 0 R12: 0 SP : 10001BC8 LR : E3AF PC : 23D5A xPSR : 61000000 PSP : 10001BA8 MSP : 1005FF70 CPUID: 410FC241 HFSR : 40000000 MMFSR: 0 BFSR : 82 UFSR : 0 DFSR : 0 AFSR : 0 BFAR : B1D84601 Mode : Thread Priv : Privileged Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++ Error Status: 0x80FF013D Code: 317 Module: 255 Error Message: Fault exception Location: 0x23D5A Error Value: 0x10006800 Current Thread: rtx_idle Id: 0x100016A4 Entry: 0xE2B9 StackSize: 0x200 StackMem: 0x100019E8 SP: 0x10001BC8 For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=SFE_ARTEMIS_NANO  MbedOS Error Info –

kerryeven commented 4 years ago

Fix for Nano not printing with Serial.print in file: 2.01/variants/SFE_ARTEMIS_NANO/variant.cpp

Edge2 variant.cpp does not have this line and prints fine. 115200 works better than 9600 which looses char's.

kerryeven commented 4 years ago

1st nano still not working on 2.0.2 (does blink on 1.0.30). Tried 2nd nano and that one WORKS!.

So...Here is a working blinky with Serial with caveats - note the variant.cpp line I had to comment out:

//Working Blinky but MUST CONNECT TERMITE AT LEAST 2 SECONDS AFTER UPLOAD DONE // OR AFTER BLINK STARTS OR IMMEDIATE LOCKUP - DOESN'T EVEN PRINT Booting... //When it does print, the first char is an umlaut (u with 2 dots above it).

void setup() { Serial.begin(115200); //115200 and 9600 caused led to freeze on - no blink // comment out Serial stuff and it works fine. //but if... //in file 2.0.2/variants/SFE_ARTEMIS_NANO/variant.cpp // comment out UART Serial1(SERIAL1_TX, SERIAL1_RX); // and Serial works. delay(100); // Serial.println(""); Serial.println("Booting....."); //Booting does print pinMode(LED_BUILTIN, OUTPUT); Serial.println("Will now begin blinking..."); }

// the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) Serial.println("LED_BUILTIN is on..."); //If Termite emulator is started before or // immediately after upload, does not // print Booting & no LED on or blink //But // If Termite is put online after the // light starts to blink, it will run normally

delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW Serial.println("LED_BUILTIN is off..."); //does not even print Booting & no LED unless // connect Termite after blinking starts.

//Termite online before loop starts kills execution! delay(1000); // wait for a second }

oclyke commented 4 years ago

Working Blinky but MUST CONNECT TERMITE AT LEAST 2 SECONDS AFTER UPLOAD DONE

Excellent - we have recently identified the same error mode. Here's the issue: https://github.com/sparkfun/Arduino_Apollo3/issues/254 We will be looking into it.

Is it appropriate to close this issue in favor of the other?

kerryeven commented 4 years ago

I would vote to leave it open as the serial for the Nano is referring to the DAPLink uart?  I needed to comment out the reference to get it to work so needs to be changed in core? Also, I haven't checked since 2.0 but I could not get the LED's on Edge2 to light. Thanks, K On Tuesday, October 20, 2020, 02:12:13 PM EDT, Owen notifications@github.com wrote:

Working Blinky but MUST CONNECT TERMITE AT LEAST 2 SECONDS AFTER UPLOAD DONE

Excellent - we have recently identified the same error mode. Here's the issue:

254

We will be looking into it.

Is it appropriate to close this issue in favor of the other?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.