Questions tagged [avr]

AVR refers to two families of either 8- or 32-bit RISC microcontrollers

The AVR is a modified Harvard architecture 8-bit RISC single chip microcontroller which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to One-Time Programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

External links:

2299 questions
5
votes
2 answers

AVR C compilers behavior. Memory management

Do AVR C compilers make program memorize the address in SRAM where function started to store its data (variables, arrays) in data stack in one of index registers in order to get absolute address of local variable by formula: absoluteAdr =…
Kuznetsov S.A.
  • 169
  • 2
  • 11
5
votes
2 answers

AVR C++ uint32_t weird behaviour

uint32_t a = 65536; uint32_t b = 1 << 16; Why is a != b here, but uint32_t a = 65536; uint32_t b = 65536; here a == b although it should technically be the same? I'm using CLion as an IDE and CMake 3.7.1 with Arduino CMake.
aquaatic
  • 87
  • 9
5
votes
1 answer

What alignment is needed on 8-bit AVR?

I would have expected the 8-bit AVR platform to not require any alignment. However, I've found the following comment in an LLVM commit: The previous data layout caused issues when dealing with atomics. For example, it is illegal to load a 16-bit…
Cactus
  • 27,075
  • 9
  • 69
  • 149
5
votes
1 answer

How can I avoid this off-by-one error when adding an offset to a prescaled hardware timer?

I am writing a microcontroller interrupt that needs to add an offset to one of its hardware timers. However, due to the way the timer prescaler works, the naive approach can introduce an off-by-one error depending on the timing of the interrupt…
AJMansfield
  • 4,039
  • 3
  • 29
  • 50
5
votes
1 answer

AVR timer overflow interrupt not working

Hello good people of stack overflow. My problem is an interrupt service routine (ISR) that seemingly never executes! Here's some info on my set up: I am flashing an avr attiny85. I have the bare bones of a project set up so far with simply a…
chen
  • 187
  • 5
  • 16
5
votes
2 answers

ADC only working once on ATMEGA324PA

I have some code which should read the values of a couple of ADC pins, each time around the commutator loop. static uint16_t adc0; static uint16_t adc1; void init(void) { ... hw_configure_adcs(); ... } void loop(void) { ... …
fadedbee
  • 42,671
  • 44
  • 178
  • 308
5
votes
5 answers

Linear interpolation in direct digital synthesis

I'm working on a microcontroller DDS project in C and am having some trouble figuring out how to compute a linear interpolation to smooth the output values. The program as it stands now uses the top 8 bits of a 24 bit accumulator as an index to an…
MattyZ
  • 1,541
  • 4
  • 24
  • 41
5
votes
5 answers

Using a rotary encoder with AVR Micro controller

I'm having trouble getting a rotary encoder to work properly with AVR micro controllers. The encoder is a mechanical ALPS encoder, and I'm using Atmega168. Clarification I have tried using an External Interrupt to listen to the pins, but it seems…
Marius
  • 57,995
  • 32
  • 132
  • 151
5
votes
2 answers

Why Embedded C++ compilers not support exceptions?

I was writing a library to embedded systems and I bumped into no STL standard library easy found. But the worst news I receive is no exception support by compiler. Atmel reference manual show this Why not support exceptions on embedded…
David Kennedy
  • 370
  • 2
  • 12
5
votes
1 answer

Eclipse CDT cannot resolve uint8_t and the like

I'm using Eclipse CDT Mars 4.5.0 20150621-1200 on Linux for a firmware project involving AVR microcontrollers. Eclipse is giving me errors like "Type 'uint8_t' could not be resolved". I properly added /usr/lib/avr/include to Project properties ->…
László Monda
  • 1,647
  • 1
  • 16
  • 29
5
votes
2 answers

tinyAVR: How can one multiply by 203, 171, or 173 real fast?

Focussing on worst case cycle count, I've coded integer multiplication routines for Atmel's AVR architecture. In one particular implementation, I'm stuck with 2+1 worst cases, for each of which I seek a faster implementation. These multiply…
greybeard
  • 2,249
  • 8
  • 30
  • 66
5
votes
2 answers

Is there a way to handle heap memory fragmentation in AVR/Arduino microcontrollers?

I've been searching for a few days now without any luck. Heap memory fragmentation is a result of using malloc() and free() heavily in microcontrollers/Arduino. If using them is unavoidable, how can I defragment the heap every now and then to make…
Islam Mustafa
  • 211
  • 2
  • 11
5
votes
3 answers

8051 microcontroller kit recommendation?

I'm a first year Computer Science student looking to get started with development for micro-controllers. I'd like to use the 8051, as it's common as dirt, and is used frequently in the real world. During my junior or senior year, I'll be taking a…
LucidDefender
  • 219
  • 2
  • 4
5
votes
1 answer

USART wrong data incoming

I am writing a communication between Atmega162 and PC. On my PCB I have interface RS485 (converted from RS422 by MAX485) and it goes through ADAM-4520 transceiver into COM port. I've been testing my program in terminal and it seems strange to me,…
pasiasty
  • 71
  • 8
5
votes
1 answer

Using CMake with AVR Toolchain in Cygwin or MinGW

I'm currently trying to get a toolchain setup so I can build an AVR project from CLion. My starting point is this, specifically, the Blink example. The issue is that it, along with existing CMake for AVR examples, are all for Linux based…
Noupoi
  • 93
  • 7