I’ve been developing an end product using the Artemis module and I’ve had LOTS of problems (I actually think I made a mistake by choosing Artemis). This one has to do with the Serial.begin() blocking the sketch execution when the USB is not plugged. My design is based on the RedBoard Nano but I used a different USB-Serial converter (an FTDI FT230 instead of the CH340) which is bus powered. Mi device, however, is ment to work on batteries and use de USB to download sketches (of course) but to configure my device and download some data captured. So I need the “Serial” object and its methods to interface with the PC. The thing is that, when the USB cable is not connected, the FT230 is not powered and RX/TX pins seem to change to tristate and that also seems to be detected by the Apollo3 so that when the “Serial.begin()” is executed, the sketch gets blocked. Sounds strange but I test it thoroughly. This is the simplest (and most convincing) test sketch I’ve used.
void setup() {
pinMode(D41, OUTPUT); // D41 is a pin I can measure on my custom board
}
void loop() {
for(int i=0;i<10;i++) {
digitalWrite(D41, HIGH);
delay(1000);
digitalWrite(D41, LOW);
delay(1000);
}
Serial.begin(9600);
}
It’s just a slightly modified Blink example. When powered by a battery (FTDI chip unpowered) the pin D41 toggles 10 times and then it stops.
I haven’t been able to have a peek at the Serial.begin method (because I don’t really know where to find it) and the Apollo3 manual doesn’t say much about a related behavior for the UART module. I expect some may suggest a hardware design change but I think the Serial.begin() method shouldn’t block the code execution. It should, instead, return an error code and proceed. IMHO, anyway.
The problem is not reproducible on the Redboards most likely because the CH340 is always powered.
Any ideas will be highly appreciated.
Edit: I just realized I didn’t mentioned I’m using Arduino IDE 1.8.13 and Apollo3 boards definition version 2.0.2 (latest).