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.

1
vote
0answers
21 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 ...
0
votes
1answer
68 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, ...
0
votes
0answers
40 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 ...
1
vote
1answer
60 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: ...
0
votes
1answer
58 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 ...
2
votes
5answers
148 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....
1
vote
1answer
118 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 ...
1
vote
1answer
74 views

How to create unique label on macro definition on AVR gnu assebler

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 ...
1
vote
2answers
70 views

SPI between ATmega32 and ATmega328 is not working

I have been trying to accomplish connecting ATmega32 and ATmega328 using SPI Hardware connections: ...
1
vote
1answer
78 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 ...
1
vote
1answer
165 views

AVR-GCC initialization code

Consider the following asm.S .global main main: rjmp main Compile and dump it with these commands: ...
3
votes
2answers
183 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 ...
3
votes
1answer
120 views

Why does AVR-GCC apparently waste 6 cycles here?

This line... if (thisWindowsSinceLastFlash <=1 ) { ...complies to this code... ...
0
votes
0answers
49 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. ...
0
votes
2answers
34 views

Is it possible to access semantically connected registers generically?

I have an SPI module which has an initializer function: ...
1
vote
2answers
349 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 ...
1
vote
2answers
245 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 ...
3
votes
2answers
81 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. ...
1
vote
2answers
2k 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 ...
0
votes
2answers
698 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: ...
0
votes
1answer
184 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 ...
10
votes
1answer
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 ...
0
votes
1answer
368 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) ...
-3
votes
2answers
192 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 ...
-5
votes
2answers
486 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 ...
2
votes
1answer
274 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 ...
1
vote
1answer
229 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 ...
0
votes
1answer
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 ...
1
vote
2answers
362 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 ...
1
vote
2answers
1k views

clock frequency confusion

I am using an atmega16 micro controller with a 12MHz external crystal oscillator. But I came to know that the internal clock frequency is 1MHz I need to calculate UBRR value for serial communication. ...
3
votes
2answers
1k views

What is STM8 hardware and software interrupt latency?

Just have a first look over the STM8 lineup to compare its performance to AVR which is well know for me now. One of my the big complain to AVR was the slow reaction to interrupts especially in C ...
-2
votes
4answers
444 views

Button debouncing not working [closed]

I want to toggle a led with a push button and an ATMega16a but for some reason the toggle behavior seems a bit randomly. ...
0
votes
2answers
2k views

Difference and compatibility between AVR xxxA and xxx/xxxV series [duplicate]

This is kind of two questions(difference & compatibility), but since an extensive answer to the latter will probably include an answer to the former, I think it's okay. Anyway, on to the question:...
4
votes
2answers
1k views

ISR, volatile and ATOMIC_BLOCK

From my experience so far I am aware of the following to pay attention to when working with ISRs: An ISR should complete quickly Variables shared between an ISR and the main execution path should be ...
0
votes
1answer
153 views

ATmega1284 behaving erratically

My ATmega1284 MCU appears to behave strangely in a number of ways. I know, I'm nuts, but here it goes... I'm using a usbtiny AVR pocket programmer with avrdude on Ubuntu Linux 15.10. I am wondering if ...
2
votes
2answers
583 views

How do I enable the internal 32MHz clock on an XMEGA avr in assembly?

This is the C code that I currently use to enable the 32MHz clock: ...
0
votes
2answers
415 views

Atmega 16 - Timer0 with interrupt

In this code the one LED is glowing at one pin PC0 with flash every 50 ms. It has XTAL of 16 MHz. With CPU frequency 16 MHz, even a maximum delay of 16.384 ms can be achieved using a 1024 prescaler. ...
1
vote
1answer
384 views

Can't get AVR pin change interrupt to work

I'm trying to get a pin change interrupt on an Attiny2313 to work but i'm stuck, the interrupt is not triggering. I'm using the following code in main(): ...
1
vote
1answer
234 views

AVR Sleep Mode Clarification

I have been learning about the AVR sleep modes as I would like to start using them in my future projects. I think I have understood the most of it except some specific details below Under Power ...
0
votes
1answer
382 views

ADC neglects input voltage (ATMega32)

In the following AVR code, why do I always see the same voltage for all pins of port A? I am using ATMega32. BTW, when I am grounding some pins of port A I do not see any change in the output. It ...
1
vote
1answer
448 views

Memory Leak in queue linked list, avr c

I am building a small command interpreter to be run on a microcontroller. To queue each command and its accompanying arguments, I am using a queue implemented as a singly linked list. All of the queue ...
0
votes
1answer
507 views

AVR global variable modified by interrupt not persistant

Using an ATmega328p, I'm running into a problem when I make an interrupt (INT0 or INT1) active, the code will execute just fine (MusicOnLed and FadeOnLed functions will execute), however as soon as I ...
0
votes
1answer
13k views

Receiving a whole string from USART on ATMEGA16?

I am trying to receive a string from USART but failed , i want to receive char by char and store them in an array until the user enter '\n' and finally display the string to LCD , here is my code: <...
1
vote
1answer
695 views

Atmel printf formatting doesn't work, no formatting does work

We are running an Atmel AVR32 chip on our board, and recently discovered that printf with format/conversion specifiers doesn't work. A regular ...
9
votes
4answers
2k views

Why GCC compiler omitting some code?

I can not understand why GCC compiler cutting out part of my code while it preserve absolutely the same one in the neighborhood? The C code: ...
-1
votes
1answer
987 views

atmega32 is working OK but atmega32A is NOT!

I have a board which there is an LCD on it and I want to show some lines in the LCD. I have a broken-pin Atmega32 which the broken pins didn't used for LCD, I have written a simple code which just ...
4
votes
1answer
378 views

How to connect a large exisiting code (some simulator) to the AVR Studio Simulator?

Context I am working on a brushless DC motor controller project. And I would like to verify that the interrupt timings make sense in simulation before downloading my code to the board. Challenge ...
2
votes
2answers
849 views

How can I bind a local variable to AVR's rXX register?

I need to have programmable pause with precision as high as possible. To accomplish this I have the following GCC code: ...
1
vote
1answer
429 views

AVR SPI2X has no effect

I've got an ATMega88A configured to run on internal 8MHz clock: lfuse = 0xE2 hfuse = 0xDF efuse = 0x01 F_CPU defined as 8000000 This in confirmed in the 'real ...
2
votes
1answer
918 views

AVR program code location

I'm working with an ATmega328P and I wanted to interface with the flash memory writing data to it with the macros provided by avr-libc. This is the memory map for my chip: ATmega memory map http://...