Skip to main content
Filter by
Sorted by
Tagged with
93 votes
4 answers
88k views

I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. If I were writing this to run on my Linux box, I could use ...
Johan's user avatar
  • 3,210
81 votes
10 answers
80k views

I want to write a C code firmware for Atmel AVR microcontrollers. I will compile it using GCC. Also, I want to enable compiler optimizations (-Os or -O2), as I see no reason to not enable them, and ...
Denilson Sá Maia's user avatar
68 votes
3 answers
58k views

Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined reference to `__cxa_pure_virtual' I've found this document which states: The __cxa_pure_virtual ...
Matthew Murdoch's user avatar
230 votes
21 answers
85k views

I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this? There is ...
Matthew Murdoch's user avatar
27 votes
8 answers
34k views

I have encountered a problem in a C program running on an AVR microcontroller (ATMega328P). I believe it is due to a stack/heap collision but I'd like to be able to confirm this. Is there any way I ...
Matthew Murdoch's user avatar
9 votes
7 answers
5k views

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 ...
Matthew Murdoch's user avatar
8 votes
8 answers
16k views

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 ...
FarK's user avatar
  • 656
3 votes
2 answers
2k views

Hi i am new in avr asm programming,in the example below, i have few questions: 1) Is it label: 8 bit or 16bit long? 2) Why multiplication label with 2 is needed? 3) Instruction LPM is placing ...
user16401's user avatar
  • 193
3 votes
6 answers
40k views

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 ...
Loïc G.'s user avatar
  • 3,177
3 votes
2 answers
4k views

I am using AVRDUDE for Android (http://code.google.com/p/andavr/). I can compile the C code. I can run $ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c $ avr-gcc -mmcu=atmega328p ...
HansStam's user avatar
  • 519
1 vote
1 answer
1k views

I'm currently in the process of writing an intermediate-memory bootloader for an ATMega. I'd like to place a section of commonly used functions and data in a specific location in memory, such that: ...
lberezy's user avatar
  • 460
13 votes
9 answers
12k views

In order to ensure that some initialization code runs before main (using Arduino/avr-gcc) I have code such as the following: class Init { public: Init() { initialize(); } }; Init init; Ideally I'...
Matthew Murdoch's user avatar
12 votes
1 answer
18k views

Using avr-gcc, avr-ld I'm attempting to severely reduce the size of the output file by using fdata-sections -ffunction-sections and gc-sections. When compiled without these options I have an output ...
Brandon Schaefer's user avatar
8 votes
1 answer
7k views

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 ...
MightyPork's user avatar
8 votes
3 answers
9k views

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 ...
MrAureliusR's user avatar
7 votes
2 answers
2k views

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 ...
orbitcowboy's user avatar
  • 1,618
3 votes
1 answer
10k views

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 ...
Eric Diviney's user avatar
2 votes
3 answers
10k views

I'm currently working on a PWM modulator to "simulate" a car engine ignition commutation. Then, I will use it to drive another microcontroller which handles the conversion from a raw signal (engine's ...
bebenlebricolo's user avatar
2 votes
1 answer
2k views

I'm having some trouble compiling and linking a library that's written in assembler with my program code which is in C++. In my case it's for an AVR microcontroller using the avr-gcc suite, but I ...
QuadrupleA's user avatar
1 vote
1 answer
3k views

I guess this is a continuation of this question. I've compiled my intermediate bootloader library and have verified it working, now it's time to write some application code against it. I'm able to ...
lberezy's user avatar
  • 460
45 votes
1 answer
22k views

Recently I've been trying to debug some low-level work and I could not find the crt0.S for the compiler (avr-gcc) but I did find a crt1.S (and the same with the corresponding .o files). What is the ...
Earlz's user avatar
  • 64.3k
25 votes
4 answers
85k views

I'm new to C++ programming, but have been working in C and Java for a long time. I'm trying to do an interface-like hierarchy in some serial protocol I'm working on, and keep getting the error: ...
Bracket's user avatar
  • 432
9 votes
4 answers
604 views

On certain architectures it may be necessary to have different pointer types for otherwise identical objects. Particularly for a Harvard architecture CPU, you may need something like: uint8_t const ...
Jubatian's user avatar
  • 2,201
9 votes
2 answers
7k views

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 ...
Application Developer's user avatar
6 votes
2 answers
1k views

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 ...
Chris A's user avatar
  • 1,495
5 votes
4 answers
41k views

I've a function which take an uint8_t * argument : uint8_t* ihex_decode(uint8_t *in, size_t len, uint8_t *out) { uint8_t i, hn, ln; for (i = 0; i < len; i+=2) { hn = in[i] > '9'...
Loïc G.'s user avatar
  • 3,177
5 votes
2 answers
12k views

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 ...
ChrisSSocha's user avatar
4 votes
1 answer
3k views

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 ...
Vorac's user avatar
  • 9,256
4 votes
3 answers
3k views

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 ...
user avatar
3 votes
1 answer
4k views

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 ...
Rišo Baláž's user avatar
3 votes
1 answer
96 views

The following code doesn't work in ATmega4809: #include <avr/io.h> #include <util/delay.h> void f(const char str[]) { if (str[0] == 'a'){ // <-- here is the problem!!! The program ...
Antonio's user avatar
  • 651
2 votes
1 answer
357 views

I am encountering an issue with USART communication on an ATmega328P microcontroller and would appreciate some assistance with debugging. The problem I'm facing is as follows: I have implemented USART ...
Vamsi's user avatar
  • 87
2 votes
1 answer
2k views

I am trying to use the avrfix library in a project, using Eclipse (v4.2.2) as the IDE and avr-gcc as the compiler. Both the header file (avrfix.h) and the library file (libavrfix.a) are included in ...
pmrancuret's user avatar
2 votes
3 answers
12k views

My main.c is as below #include <avr/io.h> #include<avr/interrupt.h> #include<util/delay.h> #include <string.h> #include "main.h" #include "globle.h" #include "LCD.h" int ...
user2733045's user avatar
2 votes
3 answers
8k views

I am running a C program on an AVR chip. Whenever a serial signal is heard, it runs the serial interrupt ISR (USART_RX_vect). In this method it should turn on change to = 1;. Then in my main while ...
Michael's user avatar
  • 8,811
2 votes
1 answer
617 views

A little background: I'm trying to build an AVR binary for an embedded sensor system, and I'm running close to my size limit. I use a few external libraries to help me, but they are rather large when ...
Nick Pascucci's user avatar
2 votes
3 answers
2k views

I'm writing an RPC library for AVR and need to pass a function address to some inline assembler code and call the function from within the assembler code. However the assembler complains when I try to ...
user2973's user avatar
  • 143
2 votes
6 answers
935 views

In the ArduinoUnit unit testing library I have provided a mechanism for giving a TestSuite a name. A user of the library can write the following: TestSuite suite("my test suite"); // ... suite.run(); ...
Matthew Murdoch's user avatar
2 votes
4 answers
8k views

I am trying to reproduce this 4-key-keyboard and for that I am trying to compile its source by compiling it with avr-gcc on my Linux box. I managed to solve a couple errors thrown by the compiler by ...
jippie's user avatar
  • 965
1 vote
1 answer
635 views

I want to use the newest version of avr-gcc (8.1.0) for a new project, which is not available from ubuntu's package-manager. So I compiled it myself using the build-script from this site: https://gist....
DocValle's user avatar
  • 167
1 vote
1 answer
1k views

So recently I tried to implement Software UART (TX only) for the ATTiny85. I want to drive it with the internal Timer1. The timer shall interrupt with the frequency of the Baudrate. Every ISR one bit ...
vipeout's user avatar
  • 25
1 vote
2 answers
887 views

I am trying to write a program that detects pixel level collision of bitmaps on a Teensy micro controller compiling with AVR-GCC. I am trying to work out how to calculate the position of a single byte ...
david_10001's user avatar
1 vote
2 answers
365 views

I want to add Atmega1281 architecture to my current version of gcc that i am using i.e. v3.3. The Atmega1281 is not supported in the v3.3 and its support got added in v4.2.1 . I cannot upgrade the ...
Biswajeet Sahoo's user avatar
1 vote
1 answer
4k views

void * memcpy_P( void * dest, PGM_VOID_P src, size_t n ) Could someone please tell me where the above function is implemented in the avr libc library? I can only seem to find a definition for the ...
fulhamHead's user avatar
1 vote
2 answers
275 views

i want to see output of Preprocessor calculating. Only with strings it works so: #define XSTR(x) STR(x) #define STR(x) #x #define BEGIN "test" #pragma message ".text= " XSTR(...
Umbrecht's user avatar
1 vote
1 answer
769 views

I'm having some difficulties understanding how EEPROM address space is managed. Fact is (as far as I understood): it is possible to have local variables on the EEPROM (e.g. using the EEMEM macro of ...
nandaloo's user avatar
  • 1,027
1 vote
1 answer
313 views

In AVR32 Studio (2.6) I'm trying to debug an AVR project and I get the error message "Launch failed as no binaries could be found". I can see in the console that Build is complete (an executable .elf ...
Danprime's user avatar
  • 240
1 vote
1 answer
85 views

(This is a follow up of this question) The following program doesn't work (in ATmega4809) #include <avr/io.h> void f(const char str[]) { if (str[0] == 'a') // <-- here is the problem. ...
Antonio's user avatar
  • 651
1 vote
1 answer
2k views

I writing a fast "8 bit reverse"-routine for an avr-project with an ATmega2560 processor. I'm using GNU C (WinAVR 20100110) version 4.3.3 (avr) / compiled by GNU C version 3.4.5 (mingw-vista special ...
Thomas's user avatar
  • 615
1 vote
1 answer
4k views

I have a header file lcd.h with this (shortened): #pragma once // ... const uint8_t LCD_ROW_ADDR[] = {0x00, 0x40, 0x14, 0x54}; // ... other prototypes and macros... And a file lcd.c where this ...
MightyPork's user avatar