Questions tagged [avr-gcc]

AVR-GCC is part of the GNU Compiler Collection (GCC) collection of open source compilers that targets the popular AVR microntroller produced by Atmel. It supports both the C and C++ languages.

Filter by
Sorted by
Tagged with
1 vote
1 answer
59 views

AVR-libc `uart_putchar` implementation

In AVR-libc page 143 the implementation of the function uart_putchar() is typical as the following: ...
user avatar
  • 488
4 votes
3 answers
1k views

Convert the type of calculation result in if() to uint8_t

I am writing in C using the Atmel Studio (AVR-C.) I have an if statement: if( (rxProcessing < (rxWritePos-1) ) ) Where ...
user avatar
1 vote
4 answers
108 views

Atmel SPI "wait for transmission complete" example is wrong?

I am configuring my first SPI transmission on my atmega328p. Everything seems right (My SPI interrupt ISR(SPI_STC_vect) fires when transmission is done, and I can see all SPI pins on the oscilloscope ...
user avatar
0 votes
1 answer
85 views

Where to find documentation for definitions for AVR programming in C

I wonder if there is a documentation for AVR (I am using C to program) definitions like PIN5_bm or SLEEP_MODE_PWR_DOWN, or if I ...
user avatar
14 votes
2 answers
847 views

Avr-gcc using repeated addition instead of MULU instructions

I recently compiled some C++ code for the ATmega1284P in Atmel Studio and was analyzing the timings of some routines using my scope. To my surprise, a loop I thought I had optimized was taking longer ...
user avatar
  • 836
0 votes
1 answer
96 views

Why port B5 on ATMEGA64A-AU mailfunction after enabling USART function?

I've wire up ATMEGA64A-AU based on this schematic from here: I've tried to program a blink on pin B5 which has a LED on it: ...
user avatar
  • 19
1 vote
2 answers
38 views

ATmega48PB: wdt in interrupt mode still reset the MCU

I read the datasheet and this question, but there's still something wrong here. Here my wdt init code: ...
user avatar
  • 875
1 vote
2 answers
96 views

Changing delay duration in _delay_us() changes code size

I was programming an ATtiny13A when I accidentally noticed that when I change the delay time in _delay_us() my code size changes. Here's the sample code: ...
user avatar
  • 310
0 votes
1 answer
147 views

Why the RAM 23lc1024 is not responding or give error?

I interfaced the 23LC1024 RAM module to atmega328. I have coded using embedded c on avr studio. The program flows like one byte is written to the address 0x000000 and Read data from the address ...
user avatar
0 votes
0 answers
141 views

Implementing UART driver with Interrupts and DMA - UART_RXC ISR is executed only first time a character is received

I am using ATxMega 32E5 and my current task is to rewrite existing RS485 driver and use DMA to save in my case valuable cycles (the speed is going to be multiplied by 8x going from 230k to 2M baudrate)...
user avatar
0 votes
2 answers
312 views

Linking a binary with avr-gcc from object files

I've been able to build and run binaries successfully when I compile and link in one step. However if I try compiling but not linking with the -c option to ...
user avatar
  • 55.3k
1 vote
0 answers
108 views

Relocation in MPLAB IDE X

I'm writing a bootloader for ATXMEGA256A3U. At page 14, Table 7.1 of the datasheet I know the bootloader address start at 0x20000. Using AtmelStudio I set in the linker option the following ...
user avatar
  • 875
0 votes
3 answers
73 views

Buffer exceeding ramsize do not produce error in avr-gcc

In my source code I have tried to allocate a huge buffer exceeding the RAMSIZE value (RAM of my component (ATmega324PB) is 2k). ...
user avatar
  • 171
6 votes
7 answers
2k views

Compress .hex file for micro-controller [closed]

I am currently writing a program in AVR Studio, here is the build *Memory Usage : * ...
user avatar
  • 223
0 votes
2 answers
2k views

Can I use C++ stl in avr-gcc?

I have implemented C++ queue in my codes, those I run on my PC. Now I'm programming an ATmega128 micro-controller to implement a .c code. Can I use that ...
user avatar
-1 votes
2 answers
101 views

Interfacing 4*4 keypad avr-gcc [duplicate]

I have this function for a 4x4 keypad: ...
user avatar
  • 223
3 votes
2 answers
346 views

avr-gcc keypad interfacing code problem

I have this function to read key press from a 4x3 key-board: ...
user avatar
  • 223
0 votes
1 answer
55 views

How to use output PWM in AVR

I have this code to blink an array (8-led) of led one after one: ...
user avatar
0 votes
1 answer
107 views

Atmega328p ADC - value keeps returning zero when connected

I'm currently try to connect a DS18S20 temperature sensor to the atmega328p. I have wired AVCC and AGRD to the same power rail on my breadboard as normal VCC/GRD and AREF is not connected. When I try ...
user avatar
1 vote
2 answers
1k views

AVR atmega328p - Can I use port C as digital output pins?

I'm currently trying to connect a 7x5 dot matrix to an AVR ATMega328p. I'm already using port B/D and I would like to use port C so that I have extra output pins. My question is, can I use port C as ...
user avatar
1 vote
0 answers
133 views

AVR - Timer0 is not firing if INT5 is enabled in EIMSK

I'm using an ATMEGA2560. Compiler: avr-gcc (AVR_8_bit_GNU_Toolchain_3.4.5_1522) 4.8.1 I have setup TIMER0 for periodic tasks: ...
user avatar
  • 375
1 vote
0 answers
203 views

Issue with SD Card Initialization via SPI: No CMD0 Response

I am working on a project to read files off of SD cards with an xmega128a4u via SPI. I noticed that some cards initialize without an issue. However, I have two cards that just wont. As far as I can ...
user avatar
  • 328
0 votes
1 answer
151 views

(Noob question) Placing parts of a byte in different (parts of) registers

Background: I'm trying to get a gLCD working with an Atmega328p. I got it to work quite easily, but there was one catch: the library that I found, used portB for the datapins. This was unacceptable, ...
user avatar
  • 485
1 vote
0 answers
294 views

Cannot Disable AVR ATmega32 Watchdog

I'm writing a code to enable and disable the watchdog timer in ATmega32. I'm using the function in the datasheet that disables the wdt. Also, I'm toggling led in the beginning of the code to know if ...
user avatar
1 vote
1 answer
146 views

progmem data array optimized out [closed]

I try to use a ATTiny10 to drive some APA102 LEDs. The LEDs are arranged in a 5x5 array. To draw something I stored some 'images' in PROGMEM. Program looks like this: ...
user avatar
  • 145
0 votes
1 answer
298 views

AVR NRF24L01+ No Communication, No IRQ Activity

I've been scratching my head for a few days over getting the NRF24L01+ modules to work on AVRs (ATMega328/p). I followed Gizmosnack's tutorial, not changing very much at all from his code. I've also ...
user avatar
  • 376
2 votes
5 answers
445 views

Are the AVR GPIO registers used by AVRGCC?

Most (all?) of the AVR family controllers provide some special GPIO registers. 4.8.1 General Purpose I/O Registers The lowest 16 I/O Memory addresses is reserved for General Purpose I/O Registers....
user avatar
  • 9,680
2 votes
1 answer
558 views

AVR SPI slave first byte problem

I have written a simple SPI slave on an ATMEGA328PB. It mostly works, however, I can't seem to get the first byte to be what I want. The difference between the first, second, and all other attempts ...
user avatar
  • 7,232
1 vote
1 answer
534 views

How to create unique label on macro definition on AVR GNU assembler?

On AVR GNU assembler I'm trying to create a label inside a macro definition. I would like to create a macro, which has a private lable, or unique label inside - just to be able to jump inside macro ...
user avatar
1 vote
2 answers
404 views

SPI between ATmega32 and ATmega328 is not working

I have been trying to accomplish connecting ATmega32 and ATmega328 using SPI Hardware connections: ...
user avatar
  • 123
1 vote
1 answer
270 views

ATTiny414 inline assembly operand constraints for IO pin parameter

I'm trying to use the light_ws2812 library to drive WS2812 LEDs from an ATTiny414. The core of that library is an inline assembly snippet that bitbangs the serial line. here it is with the timing-nops ...
user avatar
  • 113
1 vote
1 answer
517 views

AVR-GCC initialization code

Consider the following asm.S .global main main: rjmp main Compile and dump it with these commands: ...
user avatar
4 votes
2 answers
353 views

Strange issue with ATTiny10 + avr-gcc: counter used in ISR corrupted by global variables?

I have a very strange issue of a possible memory corruption when using global variables and a timer overflow interrupt on the ATTiny10 (using avr-gcc 4.9.2). I can't make any sense of it but managed ...
user avatar
  • 143
3 votes
1 answer
159 views

Why does AVR-GCC apparently waste 6 cycles here?

This line... if (thisWindowsSinceLastFlash <=1 ) { ...complies to this code... ...
user avatar
  • 9,315
0 votes
0 answers
61 views

Atmel AT90USBKEY2 delay wrong before dropping power

When I program my AT90USBKEY2 with dfu-programmer, the delays are wrong until I restart the board by unplugging it. ...
user avatar
  • 101
0 votes
2 answers
37 views

Is it possible to access semantically connected registers generically?

I have an SPI module which has an initializer function: ...
user avatar
  • 1,572
1 vote
2 answers
508 views

Atmega32 ADC Value not accurate

I was trying to simulate on proteus ADC with potentiometer and get the reading to control dc motor with PWM it's working but the problem is the ADC value not accurate. ADCH reach max value before ...
user avatar
1 vote
2 answers
424 views

USART ISR keeps repeating 4 times

​Hi, ​I'm having a problem with the USART_RX_vect interrupt of the ATMega 328p. The receiving works fine and I'm able to evaluate the sent bits (so it's not due to the baudrate) but everytime I send ...
user avatar
3 votes
2 answers
86 views

Unexpected bits when shifting out (ATtiny85)

I'm trying to spoof a 433 MHz remote and I have a sequence of 32 bytes that I want to repeatedly shift out to one of ATtiny85's pins. The signal then goes to a cheap Chinese-type 433 Mhz transmitter. ...
user avatar
1 vote
2 answers
3k views

How to know the size of my code in Atmel Studio

I'm new with Atmel Studio and I'm playing with ATtiny13. This mcu has 1K Bytes of Flash, 64 Bytes of EEPROM and 64 Bytes of SRAM. I would like to know how much memory (flash, eeprom and sram) my code ...
user avatar
  • 59
0 votes
2 answers
1k views

Where should an ISR be declared in a library?

Suppose I have a library consisting of TWI.h and TWI.c which contains an ISR defined according to AVR-GCC syntax. For example: ...
user avatar
0 votes
1 answer
451 views

Push button counting [closed]

I'm trying to have a button iterate a LED strip through binary. Each press would either increment +1 or -1 depending on the button. However, My code doesn't seem to store the variable in the do-while ...
user avatar
10 votes
1 answer
1k views

Why doesn't the compiler use directly LSR

Hi I've been working on a project using an Arduino Uno (so ATmega328p) where timing is quite important and so I wanted to see into which instructions the compiler was converting my code. And in there ...
user avatar
  • 239
1 vote
1 answer
812 views

ATtiny85 analog input constantly on max

I am currently getting into AVR programming and I want to read in two values from two potentiometers on the analog inputs PB3/ADC3 PB4/ADC2. I want to (just for now) light an two LEDs (PB1 and PB2) ...
user avatar
  • 37
-3 votes
2 answers
255 views

i'm using atmega32 to do an automatic railway gate project i wrote the code ,but i have a problem with it that it doesn't give me the required output? [closed]

I've a school project "automatic railway system ", i wrote the code but it works only on protues . when i burn it on the kit it doesn't work . what is the wrong with this code ?? "my project idea ...
user avatar
-5 votes
2 answers
933 views

LED not even turning on with avr [closed]

As the title states I have been having problems with programing my atmega328 to run a simple code that turns on an led the code is here ...
user avatar
3 votes
1 answer
480 views

Avr-gcc does not compile correctly without optimizations, but works (badly) with -Os

I am developing software for attiny88 with avr-gcc toolchain. This is a cheap microcontroller with 8kB program memory, 512B SRAM and 64B non-volatile EEPROM data memory. This is all sufficient for the ...
user avatar
  • 531
1 vote
1 answer
296 views

UART with PC : Reciving absurd characters in PC

I am working on a project using Atmega16 micro-controller of AVR family. I am using UART for my project. I need to send data to my PC AT 9600 baud rate via an USB-TTL converter and view the data using ...
user avatar
0 votes
1 answer
2k views

AVR 10ms timer with 8MHz clock

I want to generate a 10ms timer using ATMEGA32. The crystal used is 8MHz. Is this calculation correct TCNT0 value is correct.The prescaler value i used is 1024. is the calculation and the value 78 ...
user avatar
1 vote
2 answers
513 views

avr-gcc float macro error

When I try to compile some code with macro definition at the following definition # define _SPEED_FACTOR0 0.9 //or any float value I get the error floating ...
user avatar