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:

2091 questions
11
votes
2 answers

More detail about new AVR instructions LAC, LAS, LAT and XCH

Looking at the AVR instruction set there are four instructions added in 2010 LAC load and clear LAS load and set LAT load and toggle XCH load and exchange Does anyone know what chips have these instructions What tools support these…
old_timer
  • 62,459
  • 8
  • 79
  • 150
11
votes
3 answers

AVR Studio 5: compile C++ code

When creating a project in AVR Studio 5, it creates a .c file with following content: #include int main(void) { while(1) { //TODO:: Please write your application code } } Building this C program works just…
Mot
  • 24,166
  • 22
  • 78
  • 117
11
votes
5 answers

Convert Raw 14 bit Two's Complement to Signed 16 bit Integer

I am doing some work in embedded C with an accelerometer that returns data as a 14 bit 2's complement number. I am storing this result directly into a uint16_t. Later in my code I am trying to convert this "raw" form of the data into a signed…
secretformula
  • 6,256
  • 2
  • 30
  • 53
11
votes
1 answer

What happens with a premature 'return' in an ISR?

I'm using AVR-GCC 4.9.2, and I would like to know what happens if I do a premature return in an ISR on an AVR? ISR(USART_RXC_vect) { ... if(idx == BUFSIZE) return; ... } Will the return be translated to a reti instruction? Or…
BenjiWiebe
  • 1,885
  • 3
  • 20
  • 39
11
votes
4 answers

Turn on PC with USB-device

I want to be able to turn my PC on and off using an IR-remote sensor that is connected via USB to the PC. The sensor is a custom PCB implemented with an AVR microprocessor and V-USB software USB-implementation. Now, turning off the PC is no problem…
Jonatan
  • 3,164
  • 2
  • 30
  • 47
11
votes
4 answers

Symmetric encryption algorithm for embedded system

Looking for recommendations and some reference code for encrypting byte array in C. The problem is that I have to fit into 1KByte memory along with other routines and MCU is only 8MHz. So the size and speed is the key. I've checked Rijndael but it…
Pablo
  • 24,270
  • 32
  • 112
  • 196
11
votes
1 answer

How to tell clang not to save registers to stack?

The Goal I'm currently trying out avr-llvm (a llvm that supports AVR as a target). My main goal is to use it's hopefully better optimizer (compared to the one of gcc) to achieve smaller binaries. If you know a little about AVRs you know that you've…
SDwarfs
  • 3,074
  • 5
  • 23
  • 52
10
votes
4 answers

Ada multitasking RTOS supported with opensource cross-compilers

Which RTOSes do Ada have opensource/free cross-compilers available, with support for multitasking/multithreading? I have an Atmel AT90USB162 chip which I want to program using Ada. My first option was to use AVR-Ada for programming it, but since it…
Rego
  • 1,104
  • 1
  • 16
  • 39
10
votes
6 answers

Optimising this C (AVR) code

I have an interrupt handler that just isn't running fast enough for what I want to do. Basically I'm using it to generate sine waves by outputting a value from a look up table to a PORT on an AVR microncontroller but, unfortunately, this isn't…
Sam
  • 1,925
  • 7
  • 24
  • 35
10
votes
3 answers

Programming Arduino with Ada

I am am unable to get avr-elf-windows and WinAVR to work. I have managed to build the example supplied with avr-elf-windows (ATmega2560). But if I try and expand to use another chip or start using the WinAVR supplied packages and projects I keep…
Sean
  • 145
  • 1
  • 8
10
votes
3 answers

Why is the uploaded binary size so much smaller than the actual size?

I've only ever worked with AVRs and MSP430s, but this is true for both of them. After compiling and statically linking, my final ELF binary is around 208kB and the Intel Hex binary is about 41kB. AVRDUDE tells me it's uploading about 18kB. What's…
Andrew
  • 336
  • 1
  • 19
10
votes
2 answers

Is there a general algorithm for microcontroller EEPROM wear leveling?

I'm working on an Arduino library that will maximize the life of the AVR's EEPROM. It takes the number of variables you want to store and does the rest. This is my attempt, which does not work in all cases. Background information Atmel says each…
Nabil
  • 233
  • 3
  • 8
9
votes
2 answers

Pulse width modulation (PWM) on AVR Studio

I'm trying to use PWM for an LED on an ATmega8, any pin of port B. Setting up timers has been a annoying, and I don't know what to do with my OCR1A. Here's my code, and I'd love some feedback. I'm just trying to figure out how use PWM. I know the…
michaeljiz
  • 216
  • 1
  • 2
  • 10
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
  • 62,459
  • 8
  • 79
  • 150
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
  • 468
  • 1
  • 3
  • 13