I am uploading my sketches onto the ATmega328 via USB and FT232RL. I am using the standard setup, except for using a resonator (crystal with in-built 30pF capacitors). I use Arduino IDE.
Interestingly, there is no problem when I upload sketches from my PC. However, when I upload from Raspberry Pi (/dev/ttyUSB0), there are always mismatch errors, like this one:
avrdude: verification error, first mismatch at byte 0x0105
0x27 != 0x2f
The error numbers keep changing.
Also, there is no problem when uploading sketches to Arduino Uno from the same Raspberry Pi (/dev/ttyACM0).
Since it works on PC, this is more of an annoyance than a real problem, but I would still like to solve it.
Is it always one bit that fails? I've seen it before in other posts but don't know if it got solved. I would try some different cables first (between the FTDI and the Pi.
If you're having serial comms issues I would look at the subsystems that are responsible for making them work and if there's two thing I know in this world it's that:
There's no such thing as a free lunch
You can't have serial comms if your clock has issues
So my long worded question is, what's different about your timing setup?
Yup, the resonator effects all the timers, while you may be able to use a slow serial protocol, you are having issues with any reasonable serial speed. This is a known issue.
Why, if I may ask, did you choose the resonator and which model is it?
That resonator is perfectly capable of running anywhere between 15.5 and 16.5 MHz maybe even wider. I know very little about fundamental electronics, but I do know how to generate reliable timing down to about 2.5ns.
But here's the cool part, don't listen to me, test it for yourself. 2 machines identical except the resonator, shared signal ground and power source, same source code, and a single button connected to both machines. Do a couple billion things like taking random readings from the analog pins then do hashes with them. Just be sure not to use constants for the math or the compiler will optimize them out.
I'll bet you a glazed donut that they never finish at the same time.
It's 6 complete Unos minus the USB chips, so you have to program them with a serial adapter or another Arduino.
I recommend them because the entire 6 pack cost me $30 including shipping.
So easy to slap together a duino sandwich.
Using crystal plus two condensers did not help. About 70 eurocents of components wasted.
I think that communication protocols are robust enough to tolerate small differences in timing. Plus resonators are most probably better than your estimate.
Why do you say that? It’s datasheet says 1.1% accuracy, including temperature variation and aging effects. (0.5% without.). Your claim is more than 5 to 10x worse.
Resonators are generally accepted to be “good enough” for serial comm, and “real” arduino unos use resonators as well.
(Although, 1% error in a clock is about 14 minutes per day, which we’d consider unacceptable in a wrist-watch…)