BSFrance / BSFrance-avr

Arduino core for BSFrance AVR boards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

COM port on Windows cannot connect (& solution)

mahesh2000 opened this issue · comments

My solution for Windows 10 (based on this) needs to use both the base COM port and the Adafruit one. Pain in the neck but the only way I've been able to do it. Perhaps because of a "Device USB\[...] not migrated due to partial or ambiguous match." issue (Appendix 2) .

image

  1. After boot, there needs to be a delay for Serial to start (e.g. delay(2500); Serial.begin();), otherwise the Adafruit Feather 32u4 port won't initialize properly. See code sample in Appendix 1 below.
  2. press the Reset button twice in quick succession. White LED will fade in & out cyclically. this is the upload mode. device seems to exit this after 14 seconds. so just press it again every 10 secs.
  3. choose the basic COM port (for me, COM23)
  4. press Ctrl+U to compile & upload
  5. do step 1 periodically to keep the device in upload mode.
  6. watch carefully when compilation hits the "linking" step. ensure that the device is in upload mode (do step 1).
  7. after the upload is complete, change the COM port to the Feather 32u4 one (COM24 for me).
  8. Open the serial monitor. The Serial object doesn't seem to initialize until the Serial Monitor on your computer is opened. The code below compensates for that by using macros to replace Serial.print() and Serial.println().

Appendix 1.

Sample Blink code with serial printing.

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. 

  modified further 11 June 2022 for Lora32u4

  original:
  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // this is a simple way to do it, in which if the serial monitor on the PC isn't opened, the rest of the sketch won't run.
  //while(!Serial);

  // this is another simple way, but the sketch will run after 2.5 seconds, no matter what.
  //delay(2500);

  // now start Serial.
  //Serial.begin(115200);
  //Serial.println("started Serial");

  
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// 3. more useful way of using Serial with this device.
#define mySerialPrint(x) {if (serialStarted) Serial.print(x);}
#define mySerialPrintln(x) {if (serialStarted) Serial.println(x);}

int r = 0; // use to test whether `loop()` works even if the monitor is closed.
bool serialStarted = false; // use to ensure that `Serial.begin()` happens only once.

// the loop function runs over and over again forever
void loop() {
  if ((Serial) && (!serialStarted)) {
    Serial.begin(115200);
    serialStarted = true;
    Serial.println("Serial started");
  }

  r++;
  
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(200);                       // wait for a second
  mySerialPrint("Hello ");
  mySerialPrintln(r);
}

Appendix 2.

Device not migrated event details:

Device USB\VID_239A&PID_800C&MI_00\6&28ce87a1&0&0000 was not migrated due to partial or ambiguous match.

Last Device Instance Id: USB\VID_05C6&PID_9091&MI_00\6&8576b09&0&0000
Class Guid: {4d36e978-e325-11ce-bfc1-08002be10318}
Location Path: PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(2)#USBMI(0)
Migration Rank: 0xF000FFFFFFFF0022
Present: false
Status: 0xC0000719

References
Good explanation:
https://primalcortex.wordpress.com/2017/11/10/using-the-bsfrance-lora32u4-board-to-connect-to-the-things-network-lorawan/

https://learn.adafruit.com/adafruit-feather-32u4-basic-proto/feather-help#faq-4