Optimize Your Arduino Code with Registers

preview_player
Показать описание

For some interesting discussion and debate about the merits of doing this, see the following Reddit threads:

---------------------------------------------
Рекомендации по теме
Комментарии
Автор

Didn't realize registers were a thing. You definitely inspired some new thought today. Good work!

NTG
Автор

AVR is one of very few processor families specifically designed to be programed in assembly. Doing so is not much harder than using a higher level language. If speed and fine control over register use is what you after, assembly might be worth looking in to.
For example: You may give a routine (function) exclusive use of some of the 32 general purpose registers instead of using variables in memory, reducing the need to push and pull from stack and heap. This can give significant performance gains. Frequently called interrupts are a good target for this technique.

ezion
Автор

Hey thanks a tonne Ben! Also thank you for citing Spark Fun's video on registers!

shunnoysarkar
Автор

Now write it in asm. For example, I wrote code that does exactly the same functions as multiple libraries, spi negotiation, i2c communication, in asm, and it compiles to just over 1.5kb…. The original code is over 24kb… there again I’m an old fart who started when memory was premium… you had to be efficient.

gordmills
Автор

Reminds me the good ol' time when i had to generate a 50 Hz sinewave signal with a 68705P3 and a DAC.
I had to track every microsecond to have the right frequency.

You kids have no idea how easier it is nowadays xD

esunisen
Автор

I feel it shouldn't be necessary to bang on registers manually; That sort of thing should be resolved by the compiler.

SKNMI
Автор

Two questions:
1.Is the faster/efficient code written in C? is that the reason why delay() converted into _delay_ms()?
2. Isn't it faster to bit operate the PORTB rather than reassign it a new value?

BrainTrance
Автор

Knowledgeable information, sir how to convert delay code into millis function?

akash
Автор

Why not create a translator that will translate into registers? Wandering why Arduino IDE does not do that translation…

Johann
Автор

I strongly believe that the compiler should do that for us :( i'm disappointed.

brucemangy
Автор

Do not write it is hard to read and error-prone. Write `_BV(PB5)` or `(1<<PB5)`: it's just as fast (it gives the same generated assembly) and makes it very clear that you are fiddling with pin PB5.

edgarbonet
Автор

Very nicely done!!!! Sincere thanks!

dw
Автор

they should make macros using the constexpr that would be clean

IamSJ
Автор

Where is position of accumulator memory in arduino like as microcontroller AT89S51??? how to acces and save??

samarmany
Автор

Chat gpt said that we can store out libraries and parts of the program(Sketch) in SD card, I didn't find any video tutorial on this, how its done?

pocopoco
Автор

Any tips on finding the documentation for such registers? I always find that to be incredibly difficult.

TericT
Автор

Wow, its very helpful with complex project algorithm on arduino. Could you please share your documents about this? Thanks

imamnegeri
Автор

and how to do IF THEN ELSE in register code. great fid you make. thanks

nonaak
Автор

how to learn about the registers and keywords?

nobodyeverybody
Автор

some codes dosnot work with this methos i transfered a oled and dht sensor to this methos and it was impossible to work

osamarabee