Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

ItsyBitsy M4 Serial Communication Problem
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ItsyBitsy M4 Serial Communication Problem

by EKON on Mon Aug 03, 2020 6:50 pm

I'm attempting to communicate with ItsyBitsy M4 using a Visual Studio application that i created. I'm able to program the board and use the Arduino Serial Monitor....It works fine that way, but it doesn't connect when i try the same COM port using the VS App. The code for the M4 is shown below.

Code: Select all | TOGGLE FULL SIZE
String boardName = " ARD000124";  // Assigned Arduino Uno Serial Number

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  if(Serial.available() > 0)
  { 
    char characterReceived = Serial.read();
    if(characterReceived == '2')  // character used to request board serial number
    {
      Serial.println(boardName);
    }
  }
}

This same code and VS app worked on an Arduino Uno before. Any help is appreciated.

EKON
 
Posts: 6
Joined: Thu Mar 31, 2016 1:20 pm

Re: ItsyBitsy M4 Serial Communication Problem

by westfw on Mon Aug 03, 2020 10:32 pm

Serial.begin(9600);

On boards with native USB "emulating" a serial port, you need to wait for the port to initialize before you start outputting to it:

Code: Select all | TOGGLE FULL SIZE
  Serial.begin(9600);
  while (!Serial)
    ;  //Busy wait for port to be ready.

westfw
 
Posts: 1722
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: ItsyBitsy M4 Serial Communication Problem

by EKON on Tue Aug 04, 2020 11:22 am

Thanks, but that still didn't work.

EKON
 
Posts: 6
Joined: Thu Mar 31, 2016 1:20 pm

Re: ItsyBitsy M4 Serial Communication Problem

by EKON on Tue Aug 04, 2020 4:40 pm

Seems like my serial writes are getting through to the M4, but the reads are crashing my app. I tested it by setting pin 13 high for five seconds, and then setting it low. The M4 does exactly that. I wonder why the Uno works without any problem, but the M4 doesn't respond.

EKON
 
Posts: 6
Joined: Thu Mar 31, 2016 1:20 pm

Re: ItsyBitsy M4 Serial Communication Problem

by EKON on Thu Aug 06, 2020 5:31 pm

Found the solution. DTR must be enabled.
Attachments
SAMD51 DTR Enabled.png
SAMD51 DTR Enabled.png (37.42 KiB) Viewed 27 times

EKON
 
Posts: 6
Joined: Thu Mar 31, 2016 1:20 pm

Please be positive and constructive with your questions and comments.