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
9
votes
4 answers

How to achieve zero duty cycle PWM in AVR without glitches?

I'm trying to use hardware PWM on ATmega2560, using TC0 (an 8-bit timer), in Fast PWM mode. I need to dynamically adjust the duty cycle, and this includes zero duty cycle. However, this does not appear to be easy or even possible. Quoting the…
Ambroz Bizjak
  • 7,809
  • 1
  • 38
  • 49
9
votes
3 answers

Arduino/AVR ATmega microcontroller, random resets, jumps or variable/data corruption

I thought many programmers of Arduino/AVRs MCUs could share some of knowledge. My specific problem was this: In my case on an Atmel Atmega128 AVR. Based on ADC data I was running a loop which was doing some calculations into serial console, also…
John
  • 7,507
  • 3
  • 52
  • 52
9
votes
1 answer

Arduino Nano Timers

I want to know more about Arduino Nano timers. What timers are there? Do they produce interrupts? What code would attach an interrupt handler to them? How is delay() and delayMicroseconds() implemented... Do they use timer interrupts? (If so, how…
Jodes
  • 14,118
  • 26
  • 97
  • 156
8
votes
2 answers

Preserving sreg in AVR interrupts

What is the mechanism used to preserve the status register, sreg, in an AVR microcontroller? RETI implies that these bits are not on the stack. Is one of the general purpose registers also the sreg or something like that?
old_timer
  • 69,149
  • 8
  • 89
  • 168
8
votes
8 answers

AVR linker error, "relocation truncated to fit"

I'm trying to compile some code for an ATmega328 micro, and I want use the libraries and the core of Arduino. I'm using CMake. I have gotten to compile the core library and all objects of my code and the libraries of Arduino. But when it's linking,…
FarK
  • 566
  • 1
  • 4
  • 16
8
votes
4 answers

make: *** No rule to make target `main.o'

here is the output from the console in Eclipse: **** Build of configuration Debug for project FatFstest **** make all make: *** No rule to make target `main.o', needed by `FatFstest.elf'. Stop. I am trying to build a project using the AVR…
Nathan
  • 835
  • 3
  • 11
  • 20
8
votes
6 answers

What type is used in C++ to define an array size?

Compiling some test code in avr-gcc for an 8-bit micro-controller, the line const uint32_t N = 65537; uint8_t values[N]; I got the following compilation warning (by default should be an error, really) warning: conversion from 'long unsigned int'…
Fabio
  • 2,105
  • 16
  • 26
8
votes
1 answer

#define a tuple in C

I want to be able to define a tuple which represents the arguments needed by other macros. I think the best way to show what I want is to show an example: #include #define LED_PORT PORTB #define LED_DDR DDRB #define LED_PIN PB7 #define…
flungo
  • 1,050
  • 1
  • 7
  • 21
8
votes
3 answers

AVRISPmkII connection status: Unknown status 0x00

Well.. I've been searching on the web in many corners.. but I could not find a solution to my problem. Last time I used my AVRISP2 it worked fine. Now I get the following message when I try to write my program on the uC: avrdude: stk500v2_command():…
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
8
votes
3 answers

Passing a Port as a variable - AVR

Is it possible to use an AVR port as a variable which can be passed around? For example LED myLed(PORTA,7); //myLED hooked to PORTA, Pin 7 I would like to make LED be able to take any PORT / Pin combination, so I would rather not hard code it…
DanChianucci
  • 1,175
  • 2
  • 11
  • 21
8
votes
7 answers

Can I implement the Factory Method pattern in C++ without using new?

I'm working in an embedded environment (Arduino/AVR ATMega328) and want to implement the Factory Method pattern in C++. However, the compiler I'm using (avr-gcc) doesn't support the new keyword. Is there a way of implementing this pattern without…
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
7
votes
2 answers

How do I use clang to compile for avr (arduino)

When I search I found 7yr old results talking about a fork of clang instead of clang itself. Using avr-gcc I can compile and upload my code with avr-gcc a.cpp -DF_CPU=16000000 -mmcu=atmega2560 -Wall -Werror -Wextra -Os avr-objcopy -j .text -j .data…
Eric Stotch
  • 141
  • 4
  • 19
7
votes
3 answers

avr-gcc: (seemingly) unneeded prologue/epilogue in simple function

When trying to address individual bytes inside an uint64, AVR gcc⁽¹⁾ gives me a strange prologue/epilogue, while the same function written using uint32_t gives me a single ret (the example function is a NOP). Why does gcc do this? How do I remove…
André Kugland
  • 855
  • 8
  • 20
7
votes
2 answers

snprintf not working as expected with avr-gcc

During a debugging session, I found out that snprintf is not working as expected when compiling the code with avr-gcc. The example code should simply convert the floating point value 3999.9f into its character representation. Here is a minimal test…
orbitcowboy
  • 1,438
  • 13
  • 25
7
votes
2 answers

ignoring packed attribute because of unpacked non-POD field

The following code gives me this error when compiled with avr-g++ compiler ignoring packed attribute because of unpacked non-POD field 'float& foo::BAR' what is the reason? class foo { public: foo(float &bar); private: …
mic
  • 1,165
  • 1
  • 9
  • 8