Getting Started with Baremetal Arduino C Programming | No IDE Required [Linux SDK]

preview_player
Показать описание
When I started writing code for the Arduino, I felt like the code was abstracted too far away from the processor. While this is the intent of Arduino, I wanted to get down to a lower level. In this video, we learn how to write native C code without any of the Arduino IDE overhead and flash it directly to your Arduino. We go deep into the world of embedded microcontrollers and learn how bitmasks work, how to set and unset flags on a register, and use them all to do the Blink LED in C.

SOCIALS:

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

Great tutorial on this. I'm a retired low level C programmer (did lots of automation and motion control) and have just bought an Arduino to play with and was a little annoyed by all the high level calls to IDE functions, since I normally wrote those myself for whatever device I was working on. You just showed me how to get down to the level of coding that I wanted. Thanks!

michaelward
Автор

This tutorial is what I wanted to try for a while: getting out from arduino IDE and doing things in terminal. And, after watching I did this. With small modifications in makefile I ran same Blink example under cheap clone based on Nano with 168p. That hooked me to dive deeper. I hope more low level arduino videos from you in future :)

andriusp
Автор

In the second build command, avr-gcc -o main.o main.bin, it's crucial to specify the target frequency and controller -mmcu=atmega328p) to avoid unexpected behavior. Additionally, if the -c flag is removed from the first command, the second command becomes unnecessary, especially when dealing with single c files or libraries.

padalavamsiujpnquxgri
Автор

Holy shit how do you not have a billion followers! This is the best example of Direct to register programming I've seen

noexpert
Автор

Please do more of this, I really enjoyed the video, but this is one of my first contacts with actual c code for arduino so it's really hard (for me at least haha), and you're tutorials are amazing

fredesch
Автор

You are really good at this, the tutorials are clear and concise and exceptionally well explained. I hugely enjoy that format.

DonQuichotteLiberia
Автор

Great tutorial. I got this up an running in an evening using my new Raspberry Pi 400. All the AVR & GCC tools required are available in the Raspberry Pi repositories.

ruffrecords
Автор

We learned the fundamentals of controlling a port (pin) in this case, of an arduino shell, which is amazing. All we have to do is imagine the opportunities from here !

axelandru
Автор

Nice one, I enjoyed watching this and adding to my Arduino knowledge base. Thanks.

colydeane
Автор

There could not have been a better video explaining the concept. Really amazing. Thank you.

EulenBuch
Автор

thank god for this video! i had just gotten this and I know what you meant when you said it felt like python, all these built in functions that basically keep the actual functionality to seem like magic

DMGInfinityWarrior
Автор

This is great! When I got started with Arduino I felt that Arduino C was a crutch and there was really no resources to help transition into proper low-level coding for the AVR, I think this is a great introduction into the absolute basics for those that want to start making more performant code and get the most out of their AVRs. Arduino definitely has it's place as a teaching aid, but I think they really need to work on a proper learning path for transitioning into proper code.

Teklectic
Автор

Hi! Nice video. Just a couple of comments:

1. May be nitpicking but, _delay_ms() does not do a “nop” in a loop: it compiles to an empty loop. You may find a nop (and maybe an “rjmp .” or two) *after* the loop if the delay is not a multiple of the cycle duration, but the body of the loop is empty.

2. Recent versions of avrdude can read directly the elf file. No need to convert it to ihex.

edgarbonet
Автор

Amazing video mate. Watching this and listening to take it easy by the eagles was a unique experience reminding me of better days. I need to do something like this soon.

John-cgsx
Автор

One issue is that output file should be named "led.elf", because that is a format coming from "gcc -o" command. "bin" extension suggest that content from this file can be directly copy to Flash memory at address 0 in a microcontroller. You can extract bin format using "avr-objcopy -O binary" option.

voytechj
Автор

The best tutorial ever, you helped me a lot. Thank you

moveaxdwordptrcrow
Автор

I love bitwise operations... you can replace the set/unset code with a simple XOR to repeatedly flip the bit! Then your loop is just..

for(;;) {
PORTB ^= 1 << PORTB5;
_delay_ms(1000);
}

terezip
Автор

I am always amazed at how simple the operation of a chip like this really is. I don't in any way suggest that simple means easy, the familiarity with the underlying operations requires a lot of time at the keyboard. Thank you

jeffschroeder
Автор

Just discovered this channel! This is awesome, looking forward to more of these videos!

Sevenhens
Автор

PORTB ^= (1 << PORTB5) to toggle it. This saves you from writing 2 sections: one to set and one to clear.
Also funny to hear you bash high level functions from Arduino IDE and then be amazed by the presence of _delay_ms().

metamud