I have an Arduino 328p (custom) and I can program it using a FTDI header.
However, when I power it from the FTDI using only the RAW (5V) and GND, it only executes simple programs (example blink). If in my sketch I attempt to use SPI for example, it will just get stuck.
If I power the arduino from the FTDI with the DTR pin connected, it will work just as expected for any sketch. I can even remove the DTR pin at this point and there will be no issue.
What could be the cause of this behavior?
Can it be an issue with optiboot fast start?
PS: FTDI is configured for 5V but VCC for the Arduino is 3.3V (I'm using the MCP1703 regulator). This means that the Arduino is powered by 3.3V but the RST pin will have 5V.
PPS: The Arduino is running at 16MHz
1 Answer 1
The reason for this issue is to do with SPI.
Basically in my custom arduino I have a 4Mbit flash and it communicates over SPI. It seems that when the RST pin is connected it also automatically initializes the SPI protocol.
When the arduino is powered from RAW + GND directly from an external power source you need to initialize SPI manually.
In your sketch you need to:
#include <SPI.h>
void setup() {
SPI.begin(); // this needs to be invoked before any SPI device gets initialized
// initialize and use SPI devices
}
-
You need to initialize the SPI before use regardless.Chris Stratton– Chris Stratton2016年10月05日 17:14:16 +00:00Commented Oct 5, 2016 at 17:14
12V
, I think if it worked the other way round it would cause issues.