Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 3,077
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 ...
user avatar
  • 35.5k
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 ...
user avatar
  • 141
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 ...
user avatar
  • 1,553
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.
user avatar
  • 101k
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);...
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); // ...
user avatar
  • 35.5k
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,...
user avatar
  • 35.5k
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 ...
user avatar
  • 7,811
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 ...
user avatar
  • 16.1k
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 ...
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(...
user avatar
  • 35.5k
3 votes

How do I temporarily disable TIMER5 Interrupts?

You wrote: TIMSK5 |= OCIE5A; You mean TIMSK5 |= _BV(OCIE5A); or, equivalently, TIMSK5 |= 1 << OCIE5A;
user avatar
  • 35.5k
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 ...
user avatar
  • 16.1k
2 votes

If else statement not mutually exclusive?

Exactly one of the blocks in if{..} else {...} will be executed. Your misunderstanding is elsewhere.
user avatar
  • 2,147
2 votes

Programming ATmega2560 processor with FTDI instead of ATmega32

In fact, the basic Arduino Mega (with the ATmega 1280) utilizes an FT232RL, so yes, it will work if you connect it correctly. It is only the newer Mega2560 (along with the similar-generation Uno, etc)...
user avatar
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 ...
user avatar
  • 35.5k
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.
user avatar
  • 101k
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....
user avatar
2 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 ...
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 ...
user avatar
  • 1,290
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 ...
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);
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 ...
user avatar
  • 101k
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,...
user avatar
  • 35.1k
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 5,509
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....
user avatar
  • 2,471

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