Hi, I am working with several different Arduino boards including the Itsy Bitsy M0 Express. I have a sketch that needs to work with an Uno and this Itsy Bitsy M0 Express. The I/O between the two boards is different and I need to use conditional compilation to tell the compiler which IO to use depending upon the board being used.
Is there a preprocessor constant I can test to detect the Bitsy M0 Express, or do I just need to create one myself?
Conditional compilation for ItsyBitsy M0 Express
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Conditional compilation for ItsyBitsy M0 Express
You can use ADAFRUIT_ITSYBITSY_M0:
https://github.com/adafruit/ArduinoCore ... s.txt#L739
ex:
https://github.com/adafruit/ArduinoCore ... s.txt#L739
ex:
Code: Select all
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.print("Board is...");
#if defined(ADAFRUIT_ITSYBITSY_M0)
Serial.println("Itsy Bitsy M0!");
#else
Serial.println("unknown.");
#endif
}
void loop() {
}
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Excellent, thank you!
I have a problem with my Itsy Bitsy M0, Using Platform IO I flashed the sketch I have and now the board does not enumerate (Windows 11). When I press reset the LED next to the reset button lights red, if I press reset again while it is red I see a new COM port, but it is different than the original, plus neither Platform IO nor the Arduino IDE can connect to the board.
The LED next to USB connector is steady and pink/purplish.
What is the recommended way to recover please, and any ideas why this happened? The sketch is a working sketch tested on Uno.
Thanks again.
I have a problem with my Itsy Bitsy M0, Using Platform IO I flashed the sketch I have and now the board does not enumerate (Windows 11). When I press reset the LED next to the reset button lights red, if I press reset again while it is red I see a new COM port, but it is different than the original, plus neither Platform IO nor the Arduino IDE can connect to the board.
The LED next to USB connector is steady and pink/purplish.
What is the recommended way to recover please, and any ideas why this happened? The sketch is a working sketch tested on Uno.
Thanks again.
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Try double pressing reset to put the board in bootloader mode. Then try uploading sketch again.
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
Re: Conditional compilation for ItsyBitsy M0 Express
I already tried that. The Arduino IDE tries to start the flash process but hangs:
Code: Select all
Sketch uses 10324 bytes (3%) of program storage space. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port COM15
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
PORTS {COM7, COM8, COM15, } / {COM7, COM8, COM15, } => {}
Uploading using selected port: COM15
C:\Users\sidpr\AppData\Local\Arduino15\packages\adafruit\tools\bossac\1.8.0-48-gb176eee/bossac.exe -i -d --port=COM15 -U -i --offset=0x2000 -w -v C:\Users\sidpr\AppData\Local\Temp\arduino_build_517042/sketch_dec06a.ino.bin -R
Set binary mode
No device found on COM15
An error occurred while uploading the sketch
Send auto-baud
Set binary mode
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Does a folder with the name BOOT show up when you double press reset?
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Yes, "ITSYBOOT" shows up.
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Conditional compilation for ItsyBitsy M0 Express
OK, the board is fine then. The bootloader is still working as expected. This can happen when the sketch code does something that causes the auto-reset to not work.
Try this slightly different dance to get it unstuck:
https://learn.adafruit.com/adafruit-fea ... aq-2704880
Try this slightly different dance to get it unstuck:
https://learn.adafruit.com/adafruit-fea ... aq-2704880
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Excellent, that brought it back to life.
My issue is why Platform IO killed it with a sketch that works, at least on Uno. However, that is not an Adafruit problem :)
Very good support, thank you.
My issue is why Platform IO killed it with a sketch that works, at least on Uno. However, that is not an Adafruit problem :)
Very good support, thank you.
- sidprice
- Posts: 50
- Joined: Thu Jan 02, 2014 2:40 pm
Re: Conditional compilation for ItsyBitsy M0 Express
Just to fully close out this item, this whole issue was caused by me selecting the "adafruit_metro_m0" as the board in Platform IO. This morning I changed that to "adafruit_itsybitsy_m0" and the sketch builds, flashes, and runs on my Itsy Bitsy M0.
Thanks again!
Thanks again!
Please be positive and constructive with your questions and comments.