After uploading the sketch below to my Moteinos, pin 11 will be high.
If one uses a wire to ground the RST pin, after bootup pin 11 will be high.
In contrast, if the power is removed then restored, after bootup pin 11 will be low.
Of course, pin 11 should be low in all of the above cases.
/* testPin11.ino
pin 11 should always be LOW
*/
void setup() {
digitalWrite(11, LOW);
pinMode(11,OUTPUT); // pin 11 should always be LOW
pinMode(9,OUTPUT); // just to flash LED
}
void loop() {
digitalWrite(9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);
}
Using a pulldown resistor should not be needed, and indeed has no effect.
Same behaviour on 2 Moteinos.
Both Moteinos work fine in applications that use that same pin as MOSI for SPI.
Has anyone else experienced the above behavior? Give it a try please. Thanks!
Quote from: linear on July 24, 2015, 05:52:40 PM
After uploading the sketch below to my Moteinos, pin 11 will be high.
If one uses a wire to ground the RST pin, after bootup pin 11 will be high.
In contrast, if the power is removed then restored, after bootup pin 11 will be low.
Of course, pin 11 should be low in all of the above cases.
/* testPin11.ino
pin 11 should always be LOW
*/
void setup() {
digitalWrite(11, LOW);
pinMode(11,OUTPUT); // pin 11 should always be LOW
pinMode(9,OUTPUT); // just to flash LED
}
void loop() {
digitalWrite(9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);
}
Using a pulldown resistor should not be needed, and indeed has no effect.
Same behaviour on 2 Moteinos.
Both Moteinos work fine in applications that use that same pin as MOSI for SPI.
Has anyone else experienced the above behavior? Give it a try please. Thanks!
The bootloader included with Moteinos does use SPI on some types of 'reset' conditions to check to see if there is new code to load from flash (whether you have flash or not). Supposedly this is ONLY checked if the restart condition is a result of WDT timeout...
As you, I would expect your pinMode instruction to override whatever the startup condition was, but that does not appear to be the case. Perhaps a SPI.stop() - if there is such a thing, would free up the condition.
Tom
I would add that you should not assume any pins are in any state after start up.
Any pins you use in your sketch should be set to the mode you need in setup() and write a LOW/HIGH to start with.