avr-gcc

avr-gcc: variable must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

风格不统一 提交于 2019-12-22 00:56:25
问题 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 extending the command line with paramaters, but now I am stuck with the errors below. Thing is that quite a few demo projects on V-USB use the same libraries and throw the same errors and I don't want to wrestle through all the code to try and fix them for every project I want to check out. I

GCC linking / symbol name mangling with C++ and assembler files

天涯浪子 提交于 2019-12-20 03:53:47
问题 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 imagine this problem would apply to GCC generally. I can get .o files built from the C++ source and assembly, but linking them gives the error: > avr-gcc -mmcu=attiny84 -lm -o obj\AvrTest.elf obj\Main.o obj\i2cmaster.o obj\Main.o: In function `main': Main.cpp:(.text+0x0): undefined reference to `i2c

Avr asm label*2

我怕爱的太早我们不能终老 提交于 2019-12-19 10:26:08
问题 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 their result in register R0? If so, what does that have to do with Z? 4) Can you explaine the quoted text from the provided link: "If the address is not multiplied by two and label is at byte address 0x60 (word address 0x30), Z will point at the code stored there. I hope this clarified the addressing

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

吃可爱长大的小学妹 提交于 2019-12-18 03:39:36
问题 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 using new ? 回答1: Since the AVR compiler is based on the gcc compiler, it is very likely to support the new keyword. What exactly is the error you're getting. I'm guessing it's a link/compiler error along the lines of an undefined function, namely,

How to prevent GCC from optimizing out a busy wait loop?

半腔热情 提交于 2019-12-17 02:34:18
问题 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 they will probably generate a better assembly way faster than writing assembly manually. But I want a small piece of code not optimized. I want to delay the execution of a function by some time, and thus I wanted to write a do-nothing loop just to waste some time. No need to be precise, just wait

PID feedback & Position Controller with DC motor/encoder

放肆的年华 提交于 2019-12-14 02:03:07
问题 I'm having a hard time getting both PID feedback and positioning to run at the same time. My thought to calculate the RPM is to: start a timer and count encoder pulses using an interrupt. use some simple math to convert to RPM. reset variables used and start over. I can calculate RPM but then I can only call my PID controller after the calculation (however long I want to wait to get good resolution.) This results in very messy code. Is there a simpler method or something I'm missing? Info

How to interpret avr32-size output?

…衆ロ難τιáo~ 提交于 2019-12-13 00:43:28
问题 I have C program running on a AVR32 microcontroller (UC3C0512C). Issuing the avr32-size -A PROGRAM.elf command generates the following output: PROGRAM.elf : section size addr .reset 8200 2147483648 .rela.got 0 2147491848 .text 99512 2147491848 .exception 512 2147591680 .rodata 5072 2147592192 .dalign 4 4 .data 7036 8 .balign 4 7044 .bss 5856 7048 .heap 48536 12904 .comment 48 0 .debug_aranges 8672 0 .debug_pubnames 14476 0 .debug_info 311236 0 .debug_abbrev 49205 0 .debug_line 208324 0 .debug

Build AVR Studio 4 project in AVR Studio 5

回眸只為那壹抹淺笑 提交于 2019-12-12 02:12:43
问题 I have an AT90USB162 Minimus AVR which I want to integrate into a project. I downloaded the demo code from Minimus USB. This is a driver for using the AVR as a COM port. The project is written for AVR Studio 4, and cannot be loaded as-is in AVR Studio 5. How can I convert the project for use with AVR Studio 5? 回答1: Well, I just got to build the package. The problem is that the original sources were configured to be built in AVR Studio v.4, and mine is v.5, so I had to convert them to my

Basic I/O in Microcontroller AVR using WinAVR

廉价感情. 提交于 2019-12-11 20:13:36
问题 I want to drive a BLDC motor, i use ATMEGA32 as CPU of controller , i have a problem in reading hall effect sensor from BLDC motor this is my code : DDRB=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5); DDRD=(0<<0)|(0<<1)|(0<<2)|(0<<3); PORTD=(1<<0)|(1<<1)|(1<<2)|(1<<3); PORTB as OUTPUT and PORTD as INPUT this is main program : if (~(PORTD &(1<<0)) && PORTD &(1<<1) && ~(PORTD &(1<<2))) /// 0 1 0 { PORTB=(1<<0)|(0<<1)|(0<<2)|(1<<3)|(0<<4)|(0<<5); } else if (~(PORTD &(1<<0)) && PORTD &(1<<1) && PORTD

Very strange gpio behaviour programming ATtiny25v with avr-gcc and avrdude via a raspberry pi

佐手、 提交于 2019-12-11 16:18:49
问题 I have an ATtiny25v connected to a raspberry pi thtough SPI. I use avr-gcc to compile my code. Then I use avrdude to upload it. But I encounter a very strange phenomena : the main function is not called, and instead, the first instructions of the first function have effects on gpio... I have a led connected on portb4. ...I tried with several chip of the same model, and they all behave the same (excluding a buggy one) ...Can someone explain it ? NOTE : I omitted to detail it, but neither the