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
6
votes
1 answer

avr-ld error: "gc-sections requires either an entry or an undefined symbol"

Using avr-gcc and attempting to reduce size of binary using -ffunction-sections and -fdata-sections when compiling and linking with --gc-sections. The .lds file contains nothing: SECTIONS { } This error occurs when partial linking many .o's into a…
Brandon Schaefer
  • 451
  • 1
  • 4
  • 12
6
votes
2 answers

Changing just one byte in SD card sector

I'm implementing FAT16 on SD card with Atmega328. I often need to change just one or two bytes in the sector (512B region). I know how Flash works and that it needs to overwrite entire sector at once, but I was wondering if there maybe was some…
MightyPork
  • 18,270
  • 10
  • 79
  • 133
6
votes
1 answer

Adding UNUSED elements to C/C++ structure speeds up and slows down code execution

I wrote the following structure for use in an Arduino software PWM library I'm making, to PWM up to 20 pins at once (on an Uno) or 70 pins at once (on a Mega). As written, the ISR portion of the code (eRCaGuy_SoftwarePWMupdate()), processing an…
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
6
votes
1 answer

How does one read from an peripheral IO register using C/gcc?

I have an interrupt service routing on the AVR32. I need to read from the interrupt status register in order to cancel the interrupt. However I don't use the result of the read. I'd rather not use an asm instruction, but I am concerned that gcc will…
Robotbugs
  • 4,307
  • 3
  • 22
  • 30
6
votes
1 answer

Clean and tidy string tables in PROGMEM in AVR-GCC

I'm looking for a way to cleanly define an array of strings in PROGMEM for an AVR project. I have a command line processor that needs a list of command strings. The traditional way to do it on the AVR architecture is to define each string…
user1522973
6
votes
5 answers

How to reverse a byte

I am currectly working on a project and it happens that I have to reverse the order of a byte. I am currently using AVR Studio Mega32 Microcontroller. For example: 0000 0001 becomes 1000 0000 0001 0110 becomes 0110 1000 1101 1001 becomes 1001…
stefana
  • 2,606
  • 3
  • 29
  • 47
6
votes
2 answers

Why is this code being generated by avr-gcc and how does it work?

This is a snippet of disassembled AVR code from a C project I'm working on. I noticed this curious code being generated, and I can't understand how it works. I'm assuming it's some sort of ridiculous optimization... What is the explanation? 92: …
Mark Renouf
  • 30,697
  • 19
  • 94
  • 123
6
votes
4 answers

Initializing a variable and specifying the storage address the same time: is it possible?

In the codevision compiler for Atmel processors, there is a possibility to specify the storage address of a global variable, for example int a @0x100; // will place the variable at the address 0x100 in RAM Of course, as per standard C, variables…
vsz
  • 4,811
  • 7
  • 41
  • 78
6
votes
2 answers

FFT bin width clarification

I'm developing a spectrum analyzer for the 8bit Atmega32 that outputs onto a LCD display. The maximum sampling frequency is 40kHz, and maximum frequency is hence 20kHz, adhering to fs > 2B. At the moment, I am generating a signal internally, then…
Ospho
  • 2,756
  • 5
  • 26
  • 39
5
votes
2 answers

Avoiding accidental firmware overwrite

First some background. When firmware for whatever reason crashes (e.g. stack overflow, corrupted function pointer...) it may happen, that it jumps somewhere and starts executing some code. This will sooner or later result in watchdog reset. MCU will…
Stefan
  • 326
  • 2
  • 4
5
votes
5 answers

Finding position of '1's efficiently in an bit array

I'm wiring a program that tests a set of wires for open or short circuits. The program, which runs on an AVR, drives a test vector (a walking '1') onto the wires and receives the result back. It compares this resultant vector with the expected data…
saad
  • 1,225
  • 15
  • 31
5
votes
2 answers

GCC compile-time floating point optimization

I'm developing for the AVR platform and I have a question. I don't want the floating point library to be linked with my code, but I like the concept of having analog values of the range 0.0 ... 1.0 instead of 0...255 and 0...1023, depending on even…
user529758
5
votes
4 answers

ATtiny167 and Attiny87 NOT backwards compatible due to JMP vs RJMP. How to resolve

The problem I face is that the Attiny167 and Attiny87 despite on the datasheets saying they are drop in replacements are in fact not. The program is written in AVR assembly. The vector table for the Attiny87 uses RJMP meanwhile the Attiny167 uses…
goofson
  • 51
  • 1
5
votes
2 answers

Arduino (Uno) Ethernet client connection fails after many client prints

I'm using an Arduino Uno with Ethernet Shield. After sending many HTTP requests, client.println(...), the client starts to fail when connecting. The time to failure appears to be random, and the sequence readout from the loop can vary anywhere…
ChrisSSocha
  • 253
  • 1
  • 3
  • 11
5
votes
3 answers

uint64_t variable with & operations

I have a function which is searching for series of nine "1" in 64-bits variable(RFID tag number) and if found, moves them to the MSB. I have a huge problem with understanding why it does not work properly. This is my variable uint64_t volatile…
Adam Flis
  • 51
  • 4