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
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
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
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
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
4 answers

cast unsigned char * (uint8_t *) to const char *

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' ? (in[i]|32) - 'a' + 10 : in[i] - '0'; ln =…
Loïc G.
  • 3,087
  • 3
  • 24
  • 36
5
votes
1 answer

Looking for source code of __builtin_avr_delay_cycles called by _delay_ms in avr-gcc

I was investigating the delay_ms function of avr-gcc. In delay.h I found its definition: void _delay_ms(double __ms) { double __tmp ; #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ …
arminb
  • 2,036
  • 3
  • 24
  • 43
5
votes
2 answers

Array not crossing 256 byte boundary

Is it possible to create an array that doesn't cross 256 byte boundary? That is addresses of the individual array items only differ in the lower byte. This is weaker requirement than keeping the array aligned to 256 bytes. The only solution I could…
cube
  • 3,867
  • 7
  • 32
  • 52
5
votes
3 answers

Passing an array of Child objects to a function that accepts Parent*

I am working on an embedded platform with limited capabilities, so vectors/STL are not available. This may be a trivial problem, but I do not have much experience in C++ (only C and C#, which may make me blind to an obvious c++ way to do it).…
Rev
  • 5,827
  • 4
  • 27
  • 51
5
votes
2 answers

Is there a way to handle heap memory fragmentation in AVR/Arduino microcontrollers?

I've been searching for a few days now without any luck. Heap memory fragmentation is a result of using malloc() and free() heavily in microcontrollers/Arduino. If using them is unavoidable, how can I defragment the heap every now and then to make…
Islam Mustafa
  • 211
  • 2
  • 11
5
votes
3 answers

AVR Analog Comparator + Internal Pullup?

I have what I hope is a simple question pertaining to the Atmel AVR microcontrollers. So I want to use the ATTiny85's Analog Comparator to determine if a signal is above or below a threshold. This signal is normally "floating" and pulled toward…
vicatcu
  • 5,407
  • 7
  • 41
  • 65
5
votes
1 answer

gcc: division by zero

I am getting division by zero error at this line: if (tim2_st_ovf < T2_PREK_250) These values are defines like this: volatile uint8_t tim2_st_ovf = 0; #define T2_PREK_250 ((250 * (F_CPU / 1000)) / ((UINT8_MAX + 1) * 1024)) #define F_CPU …
user1806687
  • 934
  • 1
  • 10
  • 27
5
votes
1 answer

PSTR() on __FUNCTION__

Using avr-gcc it is possible to store data on Program Memory in order to save RAM. This is acomplished using PROGMEM attribute. AVR-libc also provides a macro, PSTR(), which can be used to with literal strings. Now I'm trying to use PSTR() with…
mMontu
  • 8,983
  • 4
  • 38
  • 53
5
votes
2 answers

Running an Arduino sketch with Fritzing

I am trying to learn programming on hardware, and have ordered an Arduino for that. While I wait for it to be delivered, I started to poke around and came across Fritzing. I am able to attach an LED to the microcontroller. My problem is…
Sriram
  • 10,298
  • 21
  • 83
  • 136
5
votes
2 answers

In an avr tiny, how is data meant to be stored in sram initialized when the microcontroler is powered up?

First some background. In an avr tiny, data can be stored in the registers, in the sram, in the eeprom or in the program space. Register and sram are volatile storage while the eeprom and program space are not. (ie: data stay when not powered.) When…
user1443332
  • 341
  • 2
  • 5
4
votes
2 answers

Leaving a data array (Font) in FLASH - PROGMEM in AVR GCC

Ahhh, PROGMEM, pointers, pointers to pointers, addresses of pointers... My head boggles. I have a data array for the font in question const uint8_t dejaVuSans9ptBitmaps[] = { /* @0 ' ' (5 pixels wide) */ 0x00, /* */ 0x00, /* …
mriksman
  • 309
  • 3
  • 15
1 2
3
40 41