I have been working for a long time with an Arduino UNO R3 (I've also tried Arduino Mega 2560) and I'm facing the following problems:
I compiled the program correctly regardless of the compiler used (Window7 Professional)
-Program runs correctly.
However, if I add a few rows of programs, say a subroutine, even if that subroutine does not run - the program does not execute it, the program behaves differently and incorrectly. Also, compiling this last variant with various compilers, the program also runs incorrectly and differently from one compiler to another.
What is the explanation?
I posted a subject with similar problem : Strange behaviour of Serial.print
du a declaration of a "large" string array....
I hope that these 2 known posts make the software team find the problem....
If you want, you can compare the 2 posts and problems....
For the moment, I can have a solution, but the solution limit the amount
of software and the behaviour is so strange that I am not able to know when
the data or the software where in "default" !!!
My sketch is an AD9833 frequency generator.
I use a I2C_LCD display, a 4x3 keypad (for frequency input) and two other buttons (start and pause).
The assembly has worked well for a long time, but now I would like to make certain additions to the code. Anything I'm trying to do, results in misinformation and misunderstanding of the assembly.
The sketch is compiled correctly with both Arduino 1.06, Arduino 1.5, Arduino 1.86 (on Windows 7 Pro) or Arduino Web Editor compilers.
I worked with Arduino Uno and Arduino Mega 2560.
Compilation is done successfully with all the mentioned compilers (I installed them on the computer - not all at once)
Operation is different depending on the compiler used!
It often happens that the keyboard is not read correctly, ie columns 2 and 3 of the keyboard return the characters on the first column (instead of "2" appears "1", instead of "#" appears "" etc.) after code is running a bit.
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'', '0', '#'}
I've attached the code I used.
The part of the code that I've attached to Sketch now and that is causing my problems is between lines 825 and 951.
Thank you very much.
void updateDisplay() {
char u[5];
char v[16]; //pentru program
//if (dispUnit == mHz) strcpy(u, " mHz");
if (dispUnit == Hz) strcpy(u, " Hz");
else if (dispUnit == KHz) strcpy(u, " KHz");
//else if (dispUnit == MHz) strcpy(u, " MHz");
if (prg == 1) strcpy(v, " 1 minut ");
...
...
You're writing outside the boundaries of arrays. You need to allocate one byte more to vto hold the terminating nul-character. If I counted correctly, " 1 minut " is 16 characters so no space for the terminating nul-character in variable v
You have attached a 41k ZIP file which implies that the code is considerably larger.
Nobody writes 41k of code without frequent testing as the project grows. Presumably you have an earlier version of the code that worked perfectly and then you added a small extra piece that has caused the problem. What is that small extra piece?