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 ...
Majenko's user avatar
  • 105k
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 ...
Majenko's user avatar
  • 105k
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 ...
Jot's user avatar
  • 3,216
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 ...
Edgar Bonet's user avatar
  • 42.3k
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 ...
vini_i's user avatar
  • 141
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.
Majenko's user avatar
  • 105k
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 ...
dda's user avatar
  • 1,598
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);...
101's user avatar
  • 215
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); // ...
Edgar Bonet's user avatar
  • 42.3k
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 ...
Robert Nyholm's user avatar
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,...
Edgar Bonet's user avatar
  • 42.3k
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 ...
Mikael Patel's user avatar
  • 7,959
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 ...
Juraj's user avatar
  • 17.8k
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 ...
Hoppy's user avatar
  • 159
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(...
Edgar Bonet's user avatar
  • 42.3k
3 votes

How do I temporarily disable TIMER5 Interrupts?

You wrote: TIMSK5 |= OCIE5A; You mean TIMSK5 |= _BV(OCIE5A); or, equivalently, TIMSK5 |= 1 << OCIE5A;
Edgar Bonet's user avatar
  • 42.3k
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 ...
Juraj's user avatar
  • 17.8k
2 votes

If else statement not mutually exclusive?

Exactly one of the blocks in if{..} else {...} will be executed. Your misunderstanding is elsewhere.
Mark Smith's user avatar
  • 2,181
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 ...
Edgar Bonet's user avatar
  • 42.3k
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.
Majenko's user avatar
  • 105k
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....
Avtandil Kavrelishvili's user avatar
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 ...
tttapa's user avatar
  • 1,320
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 ...
KaYBlitZ's user avatar
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);
Ignacio Vazquez-Abrams's user avatar
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 ...
Majenko's user avatar
  • 105k
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,...
Nick Gammon's user avatar
  • 37.9k
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 ...
Majenko's user avatar
  • 105k
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 ...
Duncan C's user avatar
  • 5,652
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....
VE7JRO's user avatar
  • 2,559
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 ...
Majenko's user avatar
  • 105k

Only top scored, non community-wiki answers of a minimum length are eligible