8

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 compiler option -O3 optimises the most, but there are other options you can enable, such as -funroll-loops which will cause major code bloat but speed things up. ...


7

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 SLOT_1 and once for SLOT_2. Just so fast that you think it's happening at the same time.


5

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 for example these at the top of the sketch: #pragma GCC optimize("-O3") #pragma GCC optimize("-ffast-math") The 'fast-math' is dangerous, be careful with it. ...


5

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 have to #include <avr/io.h>. Actually, you don't have to #include anything: the Arduino IDE automatically #includes Arduino.h, which in turn #includes avr/io....


4

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 there until a full read and conversion are complete. It may be possible to trigger a sample and conversion and read the answer later. Look for a chip that can ...


3

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

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 though.


3

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); // enable Timer 1 overflow interrupt ISR(TIMER1_OVF_vect) {} // Timer 1 overflow vector Note that this waveform generation mode behaves very much like the CTC ...


3

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, Phase Correct, 9-bit) rather than mode 4 (CTC).


3

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 independent of the digital pin control. Cheers! PS: See the Arduino core source code for further details on the ADC MUX control registers.


3

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 communicating with the ISP (Arduino) or is it an issue with the ISP talking to the target (ATMega8B on USBAVR)? the first error "not in sync" is a problem with ...


3

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 strange (I expected values in the range 0 - 1023, but was receiving values from 170-250 ish).


3

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(func_ptr *ptr) { (*ptr)(); } The parameter ptr is not a function pointer: it's a pointer to a function pointer. You have to dereference it twice in order to ...


3

You wrote: TIMSK5 |= OCIE5A; You mean TIMSK5 |= _BV(OCIE5A); or, equivalently, TIMSK5 |= 1 << OCIE5A;


3

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 Optiboot GithHub repository. After the updated application binary is written to free part of the flash by the running application it is necessary to copy the updated ...


2

Exactly one of the blocks in if{..} else {...} will be executed. Your misunderstanding is elsewhere.


2

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) which utilizes an ATmega16u2 or similar as the USB bridge. Generally speaking, the bootloader doesn't care - you should be able to use either target chip ...


2

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 of obvious from the picture: you would normally use the ISP connector of the target board.


2

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); TCCR1B |= (1 << WGM12); TCCR1B |= (1 << WGM13); // enable interrupt TIMSK1 |= (1 << ICIE1); // TOP value ICR1 = 100; // interrupt at TOP ...


2

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

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. Here is a video: https://www.youtube.com/watch?v=FhmG5J-AHrg


2

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 a normally closed relay and connected its control to a digital output. I normally operate with the relay closed. When I want to download a new program I open ...


2

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 the datasheet of your LEDs for the actual forward voltage, and current rating. To calculate the value for the resistor in your circuit, use Kirchhoff's and Ohm's ...


2

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 // Each array contains 32000 values const byte VALUES_1[] PROGMEM = { 1, 0, 1, .... 0 }; const byte VALUES_2[] PROGMEM = { 1, 1, 0, .... 0 }; const byte ...


2

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 anything. To get anything other than 0 out of dividing an integer by 2000 the value stored in the integer would have to be > 2000. But since you can only store a ...


2

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, to work on another processor. You would need to look at the datasheet for the Atmega2560 and see how to control its pin change interrupts.


2

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 moment in time. The current rating of a power supply is the maximum that the power supply can give. The same goes for Arduino IO and power pins: The current ...


2

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 voltage to heat. So if you feed it 12V, at 1A, it has to convert 1 amp of 12V-5V, or 7 watts of power to heat. The heat sink on the Arduino is not up to dissipating ...


2

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.available() > 0){ // 50 bytes more in compile size using parseInt() vs // char buffer and atoi(). // selection = Serial.parseInt(); Serial....


2

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 sends a short burst of the same code. This allows for a function to be run once per button press. The second sends the same code over and over again constantly ...


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