avr

AVRISPmkII connection status: Unknown status 0x00

末鹿安然 提交于 2020-01-02 02:51:10
问题 Well.. I've been searching on the web in many corners.. but I could not find a solution to my problem. Last time I used my AVRISP2 it worked fine. Now I get the following message when I try to write my program on the uC: avrdude: stk500v2_command(): command failed avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00 avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. I found many posts on the

Optimising this C (AVR) code

风流意气都作罢 提交于 2020-01-02 01:15:11
问题 I have an interrupt handler that just isn't running fast enough for what I want to do. Basically I'm using it to generate sine waves by outputting a value from a look up table to a PORT on an AVR microncontroller but, unfortunately, this isn't happening fast enough for me to get the frequency of the wave that I want. I was told that I should look at implementing it in assembly as the compiler generated assembly might be slightly inefficient and may be able to be optimised but after looking at

Fast Hypotenuse Algorithm for Embedded Processor?

半世苍凉 提交于 2019-12-29 05:55:34
问题 Is there a clever/efficient algorithm for determining the hypotenuse of an angle (i.e. sqrt(a² + b²) ), using fixed point math on an embedded processor without hardware multiply? 回答1: Unless you're doing this at >1kHz, multiply even on a MCU without hardware MUL isn't terrible. What's much worse is the sqrt . I would try to modify my application so it doesn't need to calculate it at all. Standard libraries would probably be best if you actually need it, but you could look at using Newton's

CRC-32 on MicroController (Atmel)

一个人想着一个人 提交于 2019-12-25 08:09:20
问题 I am currently trying to implement a CRC-32 for an incoming datastream (Serial communication) on an ATMEGA1280 and I am a little lost how to do this on the embedded side in C.... If anyone could point me in the proper direction and/or help in anyway i would greatly appreciate it... 回答1: You should know what polynomial you are dealing with. So it is not enough to know that you are using CRC, but you should also know polynomial. You are looking for function with this kind of prototype uint32_t

Assembly - how to set frequency of interrupt

∥☆過路亽.° 提交于 2019-12-25 05:30:21
问题 Using assembly and AVR Microcontroller I want to write program which causes the interrupt handling with a certain frequency, eg 10 Hz. first I set the stack and the timer: .cseg .org jmp restart; .org 0x002E tjmp timer_fun restart: cli ldi R16, HIGH(RAMEND) out SPH, R16 ldi R16, LOW(RAMEND) out SPL, R16 sei ldi R17, 1<<CSOO out TCCR0, R17 ldi R16, 1<<TOIE0 out TIMSK, R16 But now, I don't know how to set this frequency? 回答1: You can do this by counting the number of interrupts triggered. It

FATFS returns FR_DISK_ERR the second time I use an identical line of code

放肆的年华 提交于 2019-12-25 03:33:23
问题 I am using FATFS to write data to an SD card. It partially works and I am able to write EEPROM data to the SD card. But when I use a different function later on in the code it returns 'FR_DISK_ERR' even though I'm using the same line of code. The first time I try to write to the SD card is as follows (At this point I have already initialized the SD card and made the file, that is not the issue): //write EEPROM to EEPROM file fr = f_open(&File, file_name, FA_OPEN_APPEND | FA_WRITE); if (fr ==

How can i add a architecture which is available in new version of gcc to a old version of gcc?

陌路散爱 提交于 2019-12-25 01:49:56
问题 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 gcc to 4.2.1, so i need to add the support to my existing compiler. Is there any way to do this ? 回答1: You don't need to update GCC (I presume you are actually using AVR-GCC to generate AVR specific machine code...). All AVR chips use the same AVR core and instruction set. The only thing that

memcpy_P function AVR?

萝らか妹 提交于 2019-12-24 14:37:19
问题 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 function in a few header files, not the actual implementation. The reason I want to do this is because at the moment I am doing so performance testing on the AVRAtmega128rfa1 and I need see the AVR assembly code for the function too see how long it takes to execute. Thanks. 回答1: In avr-libc-1.8.0,

AVR汇编初探之一《AVR单片机的CPU内部结构》

别说谁变了你拦得住时间么 提交于 2019-12-24 10:57:39
学单片机那么久了,感觉想要深入,还得看汇编语言,至少得了解单片机内部结构。 下面就以ATmega16为例,介绍一下AVR单片机结构和汇编语言。 AVR单片机的CPU内核结构 如上两图,左图是虚线框内AVR CPU的内核结构,右图是AVR单片机内核结构的方框图,可以看出AVR单片机的数据总线(CPU字长)是8位的,也就说它是8位单片机。 AVR采用了Harvard结构,具有独立的数据和程序总线,CPU在执行一条指令的同时,就将PC中指定的下一条指令取出,构成了一级流水线运行方式,实现了一个时钟周期执行一条指令,数据吞吐量高达1MIPS/MHz。 AVR CPU内核由几个重要的部分组成,它们分别是: A.算数逻辑单元ALU(Arithmetic Logic Unit) AVR ALU与32个通用工作寄存器直接相连。寄存器与寄存器之间、寄存器与立即数之间的ALU运算只需要一个时钟周期。ALU操作分为3类:算术、逻辑和位操作,此外还提供了支持无/有符号数和分数乘法的乘法器,操作结果的状态将影响到状态寄存器SREG(Status Register)。 B.程序计数器PC、指令寄存器和指令译码器 程序计数器PC用来存放下一条需要执行指令在程序存储器(ROM)空间的地址(指向FlashROM空间),取出的指令存放在指令寄存器中,然后送入指令译码器中产生各种控制信号,控制CPU的运行(执行指令)。

impossible constraint in asm while compilation

此生再无相见时 提交于 2019-12-24 06:34:13
问题 In my Atmel ASF project, I am trying to build following inline asm code. However I am getting impossible constraint while compilation. Compiler points to this line __asm__ __volatile__ , am I missing anything? #define OUTPORT PORTD #define OUTBIT 3 // PD.3 uint8_t rport ,rbits; uint8_t *buf = message; asm volatile( "in __tmp_reg__, __SREG__ \n\t" // 1 Save SREG for later "cli \n\t" // 1 Clear interrupts "in %[rport], %[port] \n\t" // 1 Move PORTB adress to rport : //Outputs [rport] "=&r"