8
votes
Accepted
Will an ATmega2560 board be faster than a Uno for hard real-time data logging?
No, it will not be any faster. The extra instructions are to access the extra flash memory of the 2560. Instructions like EIJMP - Extended indirect jump, EICALL - Extended indirect call, etc.
The ...
7
votes
Accepted
If else statement not mutually exclusive?
if and else if clauses are mutually exclusive. If the if is true then the else if cannot run.
Therefore it must be the case that the code you posted is being executed twice (at least) - once for ...
5
votes
Will an ATmega2560 board be faster than a Uno for hard real-time data logging?
Use the newest Arduino IDE, because some time ago the 'lto' option was added which is a major optimization for both speed and size.
It is possible to test a few compiler options with the #pragma. Try ...
5
votes
Accepted
ADC register always returning high
First, let me give a couple of suggestions on the programming style.
There is no point in defining your own variables for accessing the
hardware registers: the avr-libc does that for you, you just ...
4
votes
Extrapolate require MCU from Arduino MEGA2560 performance
There are three things that i can see that are holding your code back.
AnalogRead in Arduino is very slow. The ADC in the chip is not the greatest but also the AnalogRead function will hold you ...
3
votes
Arduino MEGA2560 Standalone
You need more decoupling capacitors - one per VCC and AVCC pin, plus a larger (10µF) for the whole chip.
You need a pullup resistor (and maybe button) on RESET.
3
votes
Will an ATmega2560 board be faster than a Uno for hard real-time data logging?
In the platform.txt file found in ~/Arduino15/packages/arduino/hardware/avr/1.6.17 or similar, you can change the three instances of -Os with -Ofast. The size of the code can increase dramatically ...
3
votes
Is there an ICRn CTC mode interrupt vector?
It does actually seem to work with CTC mode and ICRn as TOP, by using the TIMER1_CAPT_vect interrupt.
// CTC mode with ICRn as TOP
TCCR1A &= ~(1 << WGM10);
TCCR1A &= ~(1 << WGM11);...
3
votes
Accepted
Is there an ICRn CTC mode interrupt vector?
No, there isn't. But you do have a simple alternative: use WGM 14
(fast PWM with TOP = ICR1). Then the TOV1 flag will be set after
the timer reaches TOP:
TIMSK1 |= (1 << TOIE1); // ...
3
votes
Accepted
Disable auto-reset Mega 2560 on serial monitor open using 60 ohm resistor
A 22uF cap between reset and ground does work on my Mega 2560 - opening the serial monitor will not restart the program. However, the Mega is then not downloadable. Therefore, I grounded the cap thru ...
3
votes
Accepted
Trying to run Timer1 in ATmega2560 with assembly
Here:
ldi r20, 0b00000010 ; CTC mode, int clk;
sts TCCR1A, r20
ldi r20, 0b000000101 ; prescaler /1024
sts TCCR1B, r20
you are setting the bit WGM11 on TCCR1A. The timer then runs in mode 2 (PWM,...
3
votes
Accepted
Ardunio Mega/ATmega2560: Using Port F or K for both analog inputs and digital outputs
On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o?
Yes, the ADC MUX controls the selection of the pin that is connected to the converter. This is ...
3
votes
Accepted
Help understanding how avrdude works with ArduinoISP and why its not working for me
The target board was not reset.
The "Arduino as ISP" sketch uses pin 10 to reset the target, not the SS pin. So even on Mega, wire reset of target to pin 10, not to pin 53.
Is this an error ...
3
votes
Accepted
Arduino Uno lag in simple loop
It turns out the problem was the A2 pin on the board.
When I used the A0 pin (or a different board) the problem goes away.
I realised something was wrong when I noticed the values from the pot were ...
3
votes
Accepted
Am not able to call C++ function pointers from inline assembly
It seems you got confused by the pointer indirections, which is
confounded by the implicit indirections made by the compiler.
Here:
extern "C"
void __attribute__ ((used, noinline)) call(...
3
votes
How do I temporarily disable TIMER5 Interrupts?
You wrote:
TIMSK5 |= OCIE5A;
You mean
TIMSK5 |= _BV(OCIE5A);
or, equivalently,
TIMSK5 |= 1 << OCIE5A;
3
votes
Accepted
Loading code to a mega 2560
Only from bootloader section is it possible to write to flash on ATmega2560. Optiboot 8 has a do_spm function to write to flash. It is accesible over a header file available in examples in the ...
2
votes
If else statement not mutually exclusive?
Exactly one of the blocks in if{..} else {...} will be executed. Your misunderstanding is elsewhere.
2
votes
Error while boot loading Atmega 2560 using Arduino Mega 2560
You wired the whole thing backwards. The proper wiring is
Your board - Arduino
MISO - D50
MOSI - D51
SCK - D52
Reset - D53
Vcc - 5V
GND - GND
This is kind ...
2
votes
Accepted
Controllino Debugging
Connector X1 has the pins you want.
ICSP is shared with the SPI pins. Wire those to your ICE in the same way as you wire the SPI pins of the ICSP header on a normal Arduino to an ICE.
2
votes
Accepted
Why Arduino Mega 2560 throw error when i try to upload example
I install driver for this site and everything is working well.
driver download: wch.cn/download/CH341SER_EXE.html
I'm recommend to unplug arduino first and install driver, after that plug and enjoy....
2
votes
Confusion over Transistors for a switching circuit with an Arduino Mega 2560
A transistor amplifies current, not voltage.
The first thing to check is the current of your LEDs. In your current configuration, it is between 25 and 30 mA. This is too high for most LEDs. Check ...
2
votes
PROGMEM Corrupted Array
Just a follow up in case someone else has the same problem. One solution is Nick's answer in his comment, which grabs the far addresses first in the setup, storing them in an array, and using them. I
...
2
votes
Accepted
attachInterrupt for mega 2560 not triggering
//create interrupt for button
attachInterrupt(digitalPinToInterrupt(5),count,CHANGE);
The code does not match the comment.
attachInterrupt(digitalPinToInterrupt(buttonPin),count,CHANGE);
2
votes
Accepted
Arduino loop over a function is always displaying 0 as final values
There's a couple of things wrong here:
You are just getting the last read value doubled:
x_offset += x_offset;
However x_offset is always replaced with the lates reading. You're not summing ...
2
votes
Converting code for ATTINY85 to ATMEGA2560. Pin change interupts
Each processor has different registers, things that control stuff like interrupts, input and output. I would not expect code written for one processor, especially if it directly accesses the registers,...
2
votes
Accepted
Will a 12 VDC 1A Power Supply Adapter supply too much power and damage an Arduino Mega 2560?
No. You have everything wrong there.
First off, a power supply does not provide power. It provides voltage. The device attached to it then draws current. As much current as it needs at any particular ...
2
votes
Will a 12 VDC 1A Power Supply Adapter supply too much power and damage an Arduino Mega 2560?
In addition to what Majenko told you, some additional information:
The Arudino uses a linear power supply. That type of power supply works by converting all the excess voltage above the output ...
2
votes
Accepted
Switch statement cases not executing
I think the issue is with the menuChoice() function. Try replacing it with this:
int menuChoice()
{
int selection = 0;
const byte bufferSize = 16;
char inputBuffer[bufferSize + 1];
if(Serial....
2
votes
How can i stop DC motor when button on remote is released?
For an infra-red remote control you generally can't. Those don't normally have the concept of button release.
Normally there are two kinds of buttons on a remote:
Burst code
Repeat code
The first ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
atmega2560 × 131arduino-mega × 32
interrupt × 11
serial × 10
bootloader × 10
arduino-uno × 7
timers × 7
programming × 6
avr × 6
power × 5
lcd × 5
usb × 5
avrdude × 5
arduino-ide × 4
i2c × 4
bluetooth × 4
pins × 4
spi × 4
uploading × 4
isp × 4
c++ × 3
wifi × 3
pwm × 3
shields × 3
adafruit × 3