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
7
votes
2 answers

GCC generating useless code in ISR

I have a very simple Interrupt Service Routine(ISR) written for the atmega328 and compiled with avrgcc (using -Os) using AVR studio. ISR (TIMER0_OVF_vect) { txofcnt++; //count overflows and store in uint16_t } If you note the assembly…
user1816847
  • 1,877
  • 3
  • 17
  • 29
7
votes
4 answers

Is it bad if all variables are defined as volatile on AVR programming?

I read that in some cases (global variable, or while(variable), etc.) if the variables are not defined as volatile it may cause problems. Would it cause a problem if I define all variables as volatile?
Johan Elmander
  • 497
  • 2
  • 6
  • 11
6
votes
1 answer

AMQP / RabbitMQ sender in AVR (Arduino)

Has an AMQP message sender been implemented on AVR / Arduino? Is this possible, given the limited space available on the ATmega328 I am not looking for a full implementation. Just a bare-bones "send a message". Receiving messages would be nice too,…
Dirk
  • 3,073
  • 4
  • 31
  • 36
6
votes
3 answers

Why is no serial data available on my Arduino?

I've run the simple serial program on my Arduino Uno, which just echos whatever you type to it. This works perfectly when run in the Arduino Sketch IDE (v22). int incomingByte = 0; // for incoming serial data void setup() { …
Finer Recliner
  • 1,579
  • 1
  • 13
  • 21
6
votes
4 answers

A void* being used to maintain state... (C programming)

Currently we are learning how to program AVR micro-controllers (Ansi C89 standard only). Part of the included drivers is a header that deals with scheduling ie running tasks at different rates. My question is to do with a quote from the…
Lhh92
  • 105
  • 2
  • 9
6
votes
2 answers

Using Arduino Libraries with AVR-G++

Is there a simple way to use libraries intended for the Arduino IDE with the C and assembly code I write for AVR-G++/AVR-GCC? I'm trying to use the Adafruit Wave Shield library, but simply including the header and cpp files don't do much good. Can I…
Anon
  • 5,103
  • 11
  • 45
  • 58
6
votes
2 answers

GCC inline assembly : let compiler decide what register to use for temp value

I need to load 18h and output it to port 60h, following works (inside asm("")). ldi r1, 0x18 ; 0x18 -> r1 sts 0x60, r1 ; output r1 -> 0x60 I don't care if register r1 or any other is used for this. Is there an easy way to let compiler to decide…
THX-1138
  • 21,316
  • 26
  • 96
  • 160
6
votes
3 answers

Programming Languages Targeting Arduino/AVR

What programming languages or environments target Arduino or AVR besides the default C++ environment? PS: I'm using Mac OS 10.5.
None
  • 3,875
  • 7
  • 43
  • 67
6
votes
4 answers

c/c++ optimize for constant variable in calling functions

C/C++ compilers optimize single layer functions with constant parameters (known at compile time) only when using -Os, -O1 and -O2. They do not optimize all the layers. Only -O3 can do that. gcc is WinAVR 4.3.3 which does not support attribute…
keithyip
  • 985
  • 7
  • 21
6
votes
1 answer

How do I convert a signed 8-bit byte to a signed 16-bit integer in assembly?

Using an Arduino, I have to write a function in Atmel AVR Assembly for my computer science class that converts a signed 8-bit byte to a signed 16-bit integer. I am not allowed to use any branching instructions either (but skips are fine). I know…
6
votes
9 answers

Is a logical right shift by a power of 2 faster in AVR?

I would like to know if performing a logical right shift is faster when shifting by a power of 2 For example, is myUnsigned >> 4 any faster than myUnsigned >> 3 I appreciate that everyone's first response will be to tell me that one shouldn't…
Will
  • 79
  • 1
  • 3
6
votes
2 answers

C: Pass two comma separated values with a single #define

The Problem Programming re-usable modules for microcontrollers (AVR in my case) requires flexibility in general IO pins. Each pin defined by a letter (A-G) and a number (0-7). It is, however, controlled by one bit at the same positon in three…
nqtronix
  • 463
  • 3
  • 14
6
votes
3 answers

How does an AVR perform floating point Arithmetic

I'm trying to implement a support for double and float and corresponding basic arithmetic on a CPU without an FPU. I know that it is possible on all AVR ATmega controllers. An ATmega also has no FPU. So here comes the question: How does it work? If…
Alex44
  • 3,597
  • 7
  • 39
  • 56
6
votes
2 answers

Why does my Arduino Class Constructor require an argument?

I am writing a very simple Arduino class to control two motors. I have a simple class definition inside my header file Motor.h: class Motor { public: Motor(); void left(int speed); void right(int speed); void setupRight(int…
Eric Ryan Harrison
  • 759
  • 2
  • 10
  • 22
6
votes
1 answer

Cannot compile and link AVR program in OS X

I am working on a Mac with Yosemite OS X and I'm trying to compile a program in C that I could then upload onto my Arduino. I am following a tutorial. I tried going through and reinstalling avr-gcc, but I got the same output. I tried searching for…