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

Guarantees of data preservation between int32_t and float?

I'm reading through the supplied code for a demo board(specifically the DC21561A) and found this snippet of code: int32_t min_current_threshold_code; …
BTables
  • 4,413
  • 2
  • 11
  • 30
3
votes
1 answer

Create variants of hardcoded defines

I have a C source code for a microcontroller and I would show you the first part of the header: #define USART_RX_BUFFER_SIZE 256 #define USART_TX_BUFFER_SIZE 256 #define USART_RX_BUFFER_MASK (USART_RX_BUFFER_SIZE - 1) #define USART_TX_BUFFER_MASK…
Mark
  • 4,338
  • 7
  • 58
  • 120
3
votes
2 answers

accessing data from structure in flash

I am using an Atmel AVR and am trying to access data from a structure which is stored in flash (program) memory. The structure is: typedef struct { uint8_t width; uint8_t height; // row number 0 to 5 uint8_t images; // how many frames…
Russell
  • 99
  • 7
3
votes
1 answer

why the number of vector of INT0 is 1 not 2 as datasheet?

I am using an ATmega32 to do interrupt when i trying to do driver of external interrupt 0 , faced me a problem Interrupt Vectors Table in ATmega32 Interrupt Vectors code in ISR(vector) In iom32.h code , we see that ((INT0_vect " _VECTOR(1) "))…
Mina Karam
  • 124
  • 1
  • 1
  • 10
3
votes
1 answer

Why does avr-gcc add "push r1" instructions to the start of a function?

I was looking at the produced assembly of some code I had written after compiling with avr-gcc. Specifically I compiled with the -Os option. Overall the output is what I expect, but what I cannot understand is the instruction push r1 being emitted.…
Eric Urban
  • 3,671
  • 1
  • 18
  • 23
3
votes
2 answers

Implicit conversion to float using avr-gcc: uint8_t vs. uint16_t

I have a question regarding the implicit conversion of uint8_t and uint16_t using the Arduino IDE 1.8.2 (gcc 4.9.2.). The hardware is a standard Arduino (ATMega328p). I wrote a piece of code using uint8_t and decided afterwards to switch to…
random
  • 47
  • 1
  • 7
3
votes
2 answers

What does this mean? #define TIMER_PASTE_B(lft,t,rgt) lft##t##_##rgt

I found the following function definition in the ATTiny85 tone core library. I cannot figure it out what does that mean, or how it works. It is used very often to create function names, but not sure how the syntax works. Here is a trace back that I…
Sodanetworks
  • 105
  • 1
  • 9
3
votes
3 answers

Building compile-time arbitrary length arrays in program memory for AVR

I'm trying to figure out a smart-ass way to build a composite compile-time array for the AVR architecture. The array should be structured as follows: it should reside entirely in program memory; it is comprised of a continuous series of (unsigned)…
user4113344
3
votes
1 answer

Why can't AVR interrupt vectors be '__attribute__((weak))'?

I have just tried to add __attribute__ ((weak)) to one of my interrupt handler definitions and I notice the vector jump is not implemented — the interrupt body appears in the compiled binary though. Example, with "weak"…
user4113344
3
votes
3 answers

avr-gcc vs Arduino in PlatformIO

I'm using PlatformIO as an IDE for programming AVR MCUs. I'm beginning AVR programming (I have a background in C/C++ and programming on OS's, not embedded, although I have done some Arduino stuff in the past) and using PlatformIO gives me code…
Cedric
  • 889
  • 1
  • 8
  • 18
3
votes
4 answers

Writing a variadic macro which sets specific bits in an integer (bit-mask)

I'm trying to write a macro which simplifies setting multiple bits in an integer. This commonly occurs in microcontroller code when initializing configuration registers. For example, one might configure an 8-bit timer by setting 3 bits in the…
Fritz
  • 1,293
  • 15
  • 27
3
votes
1 answer

AVR-GCC: Error: garbage at end of line

I have problem with stack init lines because avr-gcc returns LED_Blink.asm:10: Error: garbage at end of line On lines: ldi r17, low(RAMEND) ldi r17, high(RAMEND) And I am confused. I have already defined RAMEND. I used avr-gcc with this…
Rišo Baláž
  • 75
  • 1
  • 4
3
votes
1 answer

How to write a custom reset() function in C for AVR-Studio?

so I've been assigned the task of writing a custom reset() function for an AVR compilation. I'm given this info - "Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset() to reset a program. I've also heard…
Eric Diviney
  • 327
  • 2
  • 5
  • 16
3
votes
1 answer

Why do we add an Offset when addressing DDRx ,PORTx in avr?

I recently started programming my Arduino (ATmega328p) using AVR and gained sufficient knowledge on using avr lib,instead of arduino IDE.I started with a blink led example. Then i tried the same eg but this time however i didnot include io.h or any…
darth
  • 169
  • 1
  • 16
3
votes
1 answer

Stripping unused library functions / dead code from a static executable

I'm compiling code for an ARM Cortex-M0 mcu with GCC arm-none-eabi-g++ (4.8.3). All is fine, but I noticed that when I include and use any function from cstdlib, all functions from that file are included as well. How to get rid of them? I'm calling…
Jan K
  • 73
  • 6