9
votes
Accepted
Why are Arduino timer registers not 0?
The Arduino core does things at startup. One of those things is to configure the timers ready for PWM operation.
Here's the relevant bits from init() in wiring.c:
// set timer 1 prescale factor ...
9
votes
Accepted
Can I program a factory fresh Atmega328P through UART pins without burning a bootloader?
No, the ATmega's ISP does not operate over the UART pins but only the ISP pins.
To program it via a UART, you need to first load a bootloader, unless your chip was pre-programmed by the vendor, ...
8
votes
Accepted
Why can't the Atmel ATtiny family delay over a minute?
This is absolutely nothing to do with "why can't the atmel attiny family delay over a minute?". It is all to do with the way that C++ works.
See my page about Integer arithmetic and overflow.
To ...
8
votes
Accepted
How does the microcontroller know which clock to use?
Burning the bootloader via the Arduino IDE also sets the fuse bits according to its configuration files.
8
votes
Accepted
How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?
The simple answer is: they are not handled at all.
According to the C and C++ standards, what you are invoking is called
undefined behavior, meaning anything can happen. In practical
terms, it means ...
7
votes
How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?
I am afraid there is no good solution to this problem. One option I do
like is to use the __flash qualifier instead of PROGMEM:
const uint8_t ram_array[] = { 1, 2, 3, 4 };
__flash const uint8_t ...
7
votes
Accepted
Pin Change Interrupt Flag timing on 1284P
When it is entered. The wording is slightly vague but I think "when the interrupt routine is executed" means the commencement of execution. Otherwise multiple pin-change interrupts could be ...
6
votes
What does an arduino sketch translate to before compilation?
The Arduino core libraries (which are nothing more than a bunch of C/C++ files - there is no such thing as the "Arduino" programming language), are compiled along with your source code. These files ...
6
votes
My Digispark board won't show up in Ports tab in Arduino IDE (OSX)
I don't think it is supposed to. The Digispark briefly connects in "bootloader" mode, which you spotted as "Vendor-Specific Device:".
Then after 5 seconds it runs the loaded sketch. If your sketch ...
6
votes
Accepted
Problem with programming digispark ATtiny85 board with Arduino IDE
i=i++; //increment by one
The result of the above statement is not defined. That is, it is not necessarily "i + 1".
See:
http://en.wikipedia.org/wiki/...
5
votes
Accepted
AVR timer overflow interrupt not working
You are misunderstanding what an overflow interrupt is. That is called when the timer overflows (ie. it reaches TOP which in the case of an 8-bit timer is 255). Since you are counting to 124 that will ...
5
votes
Good book/reference for AVR coding in pure C/C++?
First, let's make this clear: The Arduino environment does not provide a
“simplified language”: it provides a simple hardware abstraction layer
through its core library. The language is plain C++.
...
5
votes
Basic makefile for avr-gcc
The accepted answer is great as it has given me a valuable lesson in all kinds of debugging tools (avr-objdump -D has become a close friend). Namely, the line:
${OBJCOPY} -O ihex -R .eeprom $< $@
...
5
votes
Accepted
AVR (Arduino Uno) Serial.print and Serial.println only printing 1 or 2 chars
You have two issues here:
The first is that you are using the Arduino core library and failed to
initialize it. This is done automatically if you rely on the core's
supplied main(), i.e. you stick ...
5
votes
How to convert Arduino example sketch to a complete c++ project?
Basically *.ino is *.cpp without headers. So you can
rename it to *.cpp,
If you have any functions which are used before they have been defined, provide declarations for each function before its ...
5
votes
Accepted
Why we can wake Arduino Uno from sleep using only pin 2?
It's not just Pin 2 that can wake from sleep. Depending on which sleep mode you are in different interrupts (both internal and external) can wake the chip up.
The datasheet contains this helpful ...
5
votes
Accepted
What's in an Arduino?
You did not specify what Arduino board you are talking about. It would
have been useful to tag the question with the appropriate board name. In
the following, I assume you want something similar to an ...
5
votes
Equivalent to POSIX mmap() in AVR-libc
No.
First, mmap() makes almost no sense on an AVR, as there's no memory management unit or concept of process memory to configure. Some related concepts like sbrk() are occasionally implemented in a ...
5
votes
Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?
Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory.
https://majek.sh/en/writing-to-internal-flash-on-arduino/
...
5
votes
Accepted
Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?
The answer is "yes, you can use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage, very similar to an STM32 microcontroller."
One of these days I'm going to write an Arduino ...
5
votes
Accepted
Arduino Uno R3 assembly code to push a button and turn on a LED
This line:
ldi r18, 0b00100000 ;pushed button
does not match the definition of BUTTON. You are setting bit 5 of
the register, whereas the button is on bit 3. In order to avoid
this ...
4
votes
Accepted
10 bit PWM on Arduino UNO
On your code, you using analogRead but declaring the pin (A3) as output. Change it to pinMode(A3,INPUT);
Aside from that, PWM is basically a digital output which changing (HIGH and LOW) at specified ...
4
votes
Accepted
8 bit arduinos: What happens to the data in registers during a function call? During an interupt?
The compiler is capable of analyzing which registers are used by the function or ISR, so it generates prologue and epilogue code that saves the registers on the stack on entry and restores them on ...
4
votes
Why can't the Atmel ATtiny family delay over a minute?
These are the problem lines:
long offPeriod = 1 * 60 * 1000;
long onPeriod = 1 * 60 * 1000;
Even though long should hold the result, integer operations in C++ are still done in int by default. And ...
4
votes
A confusion with setting timers
If you want to output a signal at the same speed as the system clock, I would not recommend using a timer. You can output the system clock to Port B Pin 0 by programming the CKOUT fuse on the 328P.
...
4
votes
How does avrdude burn a bootloader much quicker than the Arduino IDE?
In the Arduino IDE do this:
File > Preferences > Show verbose output during: > upload (check) > OK
Tools > Burn Bootloader
After it finishes examine the output in the black console ...
4
votes
Accepted
More speed from ATMEGA328 Internal Clock
shiftOut() relies on digitalWrite(), which is dead slow by AVR
standards. You could probably get a factor 5, or even 10, by
reimplementing shiftOut() using direct port
access instead.
Using SPI (as ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
avr × 260arduino-uno × 49
atmega328 × 33
avrdude × 26
c × 23
arduino-ide × 21
serial × 16
timers × 16
bootloader × 15
attiny × 15
programming × 14
c++ × 14
arduino-mega × 13
interrupt × 13
i2c × 12
isp × 12
atmel-studio × 12
avr-gcc × 11
avr-toolchain × 10
assembly × 9
pwm × 8
uart × 7
eeprom × 7
flash × 7
isr × 7