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
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
  • 566
  • 1
  • 4
  • 16
8
votes
7 answers

Can I implement the Factory Method pattern in C++ without using new?

I'm working in an embedded environment (Arduino/AVR ATMega328) and want to implement the Factory Method pattern in C++. However, the compiler I'm using (avr-gcc) doesn't support the new keyword. Is there a way of implementing this pattern without…
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
7
votes
3 answers

avr-gcc: (seemingly) unneeded prologue/epilogue in simple function

When trying to address individual bytes inside an uint64, AVR gcc⁽¹⁾ gives me a strange prologue/epilogue, while the same function written using uint32_t gives me a single ret (the example function is a NOP). Why does gcc do this? How do I remove…
André Kugland
  • 855
  • 8
  • 20
7
votes
2 answers

snprintf not working as expected with avr-gcc

During a debugging session, I found out that snprintf is not working as expected when compiling the code with avr-gcc. The example code should simply convert the floating point value 3999.9f into its character representation. Here is a minimal test…
orbitcowboy
  • 1,438
  • 13
  • 25
7
votes
2 answers

Avr-GCC with Arduino

How can I program my Arduino in C on Ubuntu. I've heard of avr-gcc but all online tutorials seem extremely tedious and don't have options for an AVR chip with the Arduino bootloader. Can anyone help me with an easier way to install avr-gcc on Ubuntu…
7
votes
1 answer

Macro defined in main.c not visible in another included file

I have multiple C and H files In main.c I defined a macro, and in ws_driver.c I want to use it. ws_driver.h is included in main.c. main.c #define WS_PORT PORT_D8 #define WS_BIT D8 #define WS_DDR DDR_D8 #include "ws_driver.h" In ws_dirver.c I have…
MightyPork
  • 18,270
  • 10
  • 79
  • 133
7
votes
3 answers

Problems with printf() on AVR in C with floating-point

I've been getting back into C, and I've been working on an 'academic' exercise to sharpen some old skills again. My project revolves around the rather simple process of generating sines. I started out just coding for x86 on the command line (Fedora…
Aurelius
  • 414
  • 4
  • 16
7
votes
2 answers

Going through AVR assembler "hello world" code

I'm trying to write some assembly language for Arduino Duemilanove (AVR ATmega328P). Learning assembly language jointly in parallel with compiling and disassembling C code, I have got this: (Compiled with AVR_GCC) int main() { volatile int a = 0; …
Thomas
  • 8,306
  • 8
  • 53
  • 92
7
votes
1 answer

C++ Standard compliance in AVR-GCC

I'm learning to program my Arduino, but I have a pretty solid background in C++, which means that I was very disappointed to find that I couldn't use the C++ Standard Library. I've been looking around trying to find out exactly why that is, and so…
Michael Dorst
  • 8,210
  • 11
  • 44
  • 71
7
votes
4 answers

can GCC print out intermediate results?

Check the code below: #include const uint16_t baudrate = 9600; void setupUART( void ) { uint16_t ubrr = ( ( F_CPU / ( 16 * (float) baudrate ) ) - 1 + .5 ); UBRRH = ubrr >> 8; UBRRL = ubrr & 0xff; } int main(…
jippie
  • 937
  • 5
  • 15
  • 33
7
votes
4 answers

How expensive are NULL pointer arguments?

In implementing a menu on an embedded system in C(++) (AVR-Gcc), I ended up with void function pointer that take arguments, and usually make use of them. // void function prototype void (*auxFunc)(char *); In some cases (in fact quite a few), the…
falro
  • 125
  • 6
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

Arduino not compiling - bad CPU type in executable

Recently I was attempting to upload some code on my Arduino and got this error: ****Arduino: 1.8.9 (Mac OS X), Board: "Arduino/Genuino Uno" fork/exec /Users/Gu/Desktop/Every single yhing/coding…
python_man
  • 81
  • 1
  • 10
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…
6
votes
2 answers

Extern variable only in header unexpectedly working, why?

I'm currently updating a C++ library for Arduino (Specifically 8-bit AVR processors compiled using avr-gcc). Typically the authors of the default Arduino libraries like to include an extern variable for the class inside the header, which is defined…
Chris A
  • 1,475
  • 3
  • 18
  • 22
1
2
3
40 41