Questions tagged [avr-gcc]

avr-gcc is a suite of executable software development tools for Atmel AVR RISC processors

avr-gcc is a suite of executable software development tools for Atmel AVR RISC processors, hosted on the Windows platform, has GNU GCC compiler for C/C++.

Atmel provides also an AVR Toolchain, which is a collection of tools/libraries used to create applications for AVR microcontrollers. The collection includes compiler, assembler, linker and Standard C & other math libraries.

Most of these tools are based on efforts from GNU (www.gnu.org), and some are developed by Atmel.

614 questions
4
votes
3 answers

Does AVR-GCC properly work with 16-bit AVR I/O registers?

Preamble It's known that for atomic and simultaneous reading/writing high and low part of 16-bit I/O registers (timer-counters, ICR/OCR, ADC...) AVR uses a shadow temporary register. E.g. reading TCNT1 on ATmega8: uint8_t tl, th; tl = TCNT1L; //…
user1150105
4
votes
1 answer

Does gnu ld link in whole object files or only the needed functions?

We have a library and an executable, that is to be statically linked to the lib. We want to minimize the program space of the final executable. According to avr-libc's documentation: the linker links in THE ENTIRE OBJECT MODULE in which the…
Vorac
  • 8,726
  • 11
  • 58
  • 101
4
votes
1 answer

How to get GNU AS to emit per-line debugging info or GDB to single step lines in (AVR) Assembly?

I cannot figure out how to get GAS to emit line number debugging information for gdb in assembly. Note that I'm using the avr-gcc cross compiler, but doubt that is relevant. I'm using the following command line options to assemble: avr-gcc -g…
braddock
  • 1,345
  • 2
  • 11
  • 13
4
votes
2 answers

How to efficiently calculate a modulus in C by hand?

I wrote a basic fixed-point variant of the sine function which utilizes a lookup table (targeting an AVR micro controller w/o FPU). My implementation also accepts negative values and values which exceed 2π, like its floating point pendant in math.h…
3
votes
2 answers

C++; eclipse linker error

So working on getting my eclipse IDE going so I can develop my arduino uno in eclipse. My C++ is weak so this is probably a nube error on my part. I have a blink program that looks for an arduino library I compiled from the arduino IDE's…
goinidias
  • 53
  • 1
  • 6
3
votes
1 answer

Storing Large Integers/Values in an Embedded System

I'm developing a embedded system that can test a large numbers of wires (upto 360) - essentially a continuity checking system. The system works by clocking in a test vector and reading the output from the other end. The output is then compared with…
saad
  • 1,225
  • 15
  • 31
3
votes
4 answers

Compile Assembly code that includes header files containing C-definitions

I'm trying to compile assembly and C code together (not C to assembly), but can't get it done. For example: file common.h #ifndef __COMMON_H__ #define __COMMON_H__ struct tree{ tree* left; tree* right; void* elem; }; void…
Tom
  • 43,810
  • 29
  • 138
  • 169
3
votes
2 answers

Is it possible to force particular registers in inline assembly code?

I have the following assembly code: __asm__ __volatile__ ( "1: subi %0, 1" "\n\t" "brne 1b" : "=d" (__count) : "M" (__count)); which results in the following compiler ouptut ce: 81 50 subi r24, 0x01 ; 1 d0: …
w_hoami
  • 101
  • 1
  • 1
  • 8
3
votes
0 answers

std::atomic<> for avr-gcc

I wonder if it would be possible to write std::atomic<> for the use on the AVR µC. The __atomic_xxx() built-ins are unfortunately not implemented in avr-gcc. As I understand basic load/store of uint8_t on AVR is atomic, but e.g. operator++() not…
wimalopaan
  • 4,838
  • 1
  • 21
  • 39
3
votes
1 answer

Different compiler behavior when dividing unsigned char vs dividing unsigned short

I'm not very experienced in the world of C programming, I just worked with arduino before, and I decided to get my feet more wet by doing a project on an ATtiny13 without using the Arduino IDE, only avr-gcc via cli. Since Flash storage is at a…
Amine Kchouk
  • 162
  • 1
  • 11
3
votes
2 answers

Concatenate compile time constant strings with characters whose character code comes from a #define

I want to assemble a char array that contains one byte with a compile time constant value and a string, which is also compile time constant. Solution would be: char packet[] = "\x42" __DATE__; That works but is not very readable and maintainable,…
Stefan Bormann
  • 643
  • 7
  • 25
3
votes
6 answers

Convert two ASCII Hexadecimal Characters (Two ASCII bytes) in one byte

I want to convert two ASCII bytes to one hexadecimal byte. eg. 0x30 0x43 => 0x0C , 0x34 0x46 => 0x4F ... The ASCII bytes are a number between 0 and 9 or a letter between A and F (upper case only), so between 0x30 ... 0x39 and 0x41 ... 0x46 I know…
Loïc G.
  • 3,087
  • 3
  • 24
  • 36
3
votes
1 answer

Why defining buffer length of a buffer leads to that class's function member to loose the value of a function pointer member variable?

I am working with GNU AVR GCC version 5.4.0 and Atmelstudio 7.0.2397 and I have the following problem. Problem Description In the following Image, ye can see that up to line 13, the program has stored the address of function usart_send into the…
Sanmveg saini
  • 744
  • 1
  • 7
  • 22
3
votes
1 answer

Why is this code generated to dereference a float pointer?

I have this file float_deref.c that generates strange machine code: float float_deref(float *ptr) { return *ptr; } Here is the assembly generated by avr-gcc -mmcu=atmega328p -O3 -S -o - float_deref.c: .file "float_deref.c" __SP_H__ =…
JudeMH
  • 485
  • 2
  • 10
3
votes
1 answer

Why is GCC generate the code with bunch of useless JMP instruction?

I am currently working on a Bootloader in Atmel Studio for Atmega328P (Arduino UNO), and from the disassembly I found the following code (My bootloader starts from 0x3800): --- ../../../../crt1/gcrt1.S…
xandy
  • 27,357
  • 8
  • 59
  • 64