Keep making videos bro. This is one of those rare videos on youtube where a dude explains everything in a "grounds-up". This manner of explanation leaves no holes in understanding and encouraged me to review your video over and over. Keep it up!!
@dave_dennis4 жыл бұрын
I like programming as close to the metal as possible. GOOD JOB showing this and illustrating why this is superior.
@natesamuelson18412 жыл бұрын
I’ve been using a personal project as an opportunity to learn about Arduinos and the whole design process. Thought I had it all figured out until I tried to transition to the ATTiny85 and was quickly humbled. Your videos are providing the bridge to microcontrollers that I had no idea I needed and I cannot say enough how much I appreciate all of your work. It goes without saying that this step up in understanding is likely what stops most of us from going further with our projects so I can’t imagine how many doors you’ve opened for people. Thank you.
@raif10 Жыл бұрын
I've watched a ton of git manipulation/register videos lately and this is by FAR the best I have seen. Watch it and save it.
@gusmcmanus61592 жыл бұрын
This is basically a full explanation that’s bridging the gap in my knowledge between circuits and computer programs. I want to let you know how valuable this is to me and, I’m sure, to other people. Thank you for making this.
@Electromakerio4 жыл бұрын
We loved this tutorial so much we featured it in this week's Electromaker show!
@prasadsalunke23 Жыл бұрын
Criminally underrated channel this is ☝️🙂Keep up the good work ❤
@torenjk3 жыл бұрын
I dont understand how this series has such low views... Those Videos taught me so much! Thanks for that dude!
@abutaymiyyahlectures3 жыл бұрын
i think its coz no one will understand what the title of the video even means, i came here after watching his recent "beyond arduino" video. And thank god did i watch that video haha, and thank god that i came here :D
@MouradSahli3 жыл бұрын
The title is a bit obscure. Also SparkFun has a couple of videos on Atmega328 registers/ports that are quite good. Still he does a good job of explaining and chunking it and deserves all the best for his efforts.
@kevin27062 жыл бұрын
Great presentation and in depth analysis of the necessary elements to understand bare metal programming. Been looking for something to jumpstart my understanding with avr bare metal programming. Even if you applied it for STM32, it's so concise it could be applied to any MCU with the proper study of the datasheet. Well done.
@okaytokay4 жыл бұрын
Saved the playlist. Your explanations are super crystal clear. Thanks
@lamp0072 ай бұрын
Dude you make so much sense when you explain things!
@rpr424 жыл бұрын
I have just started watching this series and am enjoying it. I have been playing with the ESP32 using micropython mainly and have always been curious about digging in deeper. Great Job!
@nicholasmascioni3333 Жыл бұрын
This was really neat! Been looking for videos that explain how to do this kinda thing for a while now and this was by far the best one, can't wait to watch the rest!
@AlexSKelly-up7lf3 жыл бұрын
Man, you're killing it.
@iamolham10 ай бұрын
this guy knows alot, thank you for this amazing information and please continue sharing it
@acsaba224 жыл бұрын
Thx Mitch! I was looking for some Ben Eater style videos about understanding microcontrollers. I think I've found it!
@cthoadmin74582 жыл бұрын
This is high quality stuff Mitch! Thanks for bringing it to us... (rushing away to try the blink example myself)
@Landline377210 ай бұрын
The best explanation I've ever seen , you are best!
@brunosuperman2 жыл бұрын
The best video about this on the internet sofar! You are really didactical! Thanks you!
@nyakoi2 жыл бұрын
Thank you, exactly what I needed. Very well explained!
@louisferreira90553 ай бұрын
Hey Mitch. Just stumbled accross this series and have to say... absolutely the fkn best tutorial on AVR micros I have seen so far. In fact I'd put you up there with Ben Eater! Please, please please, do another series with new 1 Series of Attiny family, particularly the '412 which is the new '85. I have learned so much from your '85 videos, I'm literally begging you to do a 412 playlist.
@lokipuk Жыл бұрын
You are SO the best of the best. Perfect explanations
@tinkerman52207 ай бұрын
Excellent video. Very specific to registers and very watchable.
@abstractapproach6343 жыл бұрын
12:37 He wanted to make it a a BIT longer; however, could not because he wanted to keep it in a BYTE size format. So so so good, how to do you keep a straight face with golden tech puns like that............subscribed (not just for the pun, but it was icing on the cake)
@MitchDavis23 жыл бұрын
Pbbbttttt. That’s because I had no idea I did that until you just pointed it out
@meemuboi4 жыл бұрын
This was really easy to understand, well done and thank you for making these videos!
@aregjan Жыл бұрын
Wow, 18x faster with direct access ?? That's an enormous improvement, I shall do that going forward. These videos are really great .
@jameshall75392 жыл бұрын
thanks for this tutorial it teaches people how to do it in the right way
@dhanushkumar.r1175Ай бұрын
students deserve this kind of videos
@phamngocthinh59132 жыл бұрын
i love this video, it's help me can understand a lot of the information behind the function already have in Arduino. Thanks for this video
@AdilKhan-jp7hn4 жыл бұрын
Thank you for such detailed information on these avr microcontroller. Excellent content and video quality
@Dygear Жыл бұрын
For the Port B segment, might be worth showing where Port B is defined. I can't seem to find it in the headers. I'm told from a Google Search that this is in the avr tool-chain. I would imagine that it's defined with the volatile keyword to tell the compiler that the reads or writes to this value will have side effects not seen by the C code directly and thus can not be optimized out. For the Delay segment, might be worth mentioning that the clock speed is the driver of how fast the system runs. A single instruction takes at least one CPU cycle to complete and is your overall system budget on how many instructions you can do in any given second. With that in mind, a write to a variable takes 1 instruction, a read to a variable that is in the CPU register takes 1 instruction. With the STM8 running at 8MHz it can process 8,000,000 instructions in a given second. The for loop itself is setup (long i = 0) at the setup of the loop and for the purposes of this discussion is meaningless. (1 / 8,000,000 of a second). The execution of the code takes 1 instruction (PORTB = 0), the check takes one instruction (i < 1_000_000), and the increment takes one instruction (i++). One iteration of the loop cycle actually takes 3 instructions, and so each for loop is costing 3,000,001 cycles. The delay it's causing is actually around 3/8th of a second or 375 milliseconds and that is why it's blinking faster than the previous example.
@dhruvandangar99723 жыл бұрын
nice work bro. hats off to you.
@rickybobbyracing91063 жыл бұрын
Great job, I am really enjoying this series
@slowjocrow6451 Жыл бұрын
Thanks for the video 👍 Trying to learn bare metal with no previous microcontroller experience
@jackisgoofingoff55107 ай бұрын
Giving me a deep review of AVR controller, thank you
@ionizationx2 жыл бұрын
Hi Mitch, i just want to thank you for helping me out with this video. Well done! I am now able to write the right code for my project :-)
@Fornicassaurus Жыл бұрын
Great videos!!! Thanx for your time and effort!!!
@andreialexander4053 жыл бұрын
Thank you very much, Mitch, awesome, very informative videos!
@arduinomaquinas Жыл бұрын
Big show, good job, subscribed and like 1.6K full 😉👍
@luismiguelfrancisco8248 ай бұрын
This vídeo is amazing man!
@AlexanderSelyutin4 ай бұрын
excellent explanation
@Fubar123412 жыл бұрын
Brilliant video well explained and it works !
@mustardthefirst1583 Жыл бұрын
thanks
@joelclingempeel15124 ай бұрын
This guy is the Ben Eater of the embedded world!
@gustavocortico1681 Жыл бұрын
I feel like messing with bare metal is kind of an uncanny valley of physicality. Gives me a bit of a thrill.
@wrmusic87362 жыл бұрын
also a program that uses pinMode(), digitalWrite() and delay() takes 1536 bytes of flash and 9 bytes of RAM on my Mega2560, whereas a simple bitwise op function and _delay_ms() from AVR API takes only 304 bytes of flash and 0 bytes of RAM - meaning 5x times memory optimization. So yeah Arduino SDK functions are fine for prototyping, but optimizing for specific MCU pays off by a lot.
@groveraruquipa99333 жыл бұрын
Amazing video, thank you very much!!
@reeb85873 жыл бұрын
good up to the point of delay function. NOP loops are not the way to go, missed opportunity to talk about timers and interrupts
@MitchDavis23 жыл бұрын
The hardest parts of these videos are deciding what NOT to talk about. Timers and interrupts are more of an intermediate topic that I didn’t want to spend time on quite yet. I ended up doing a video on timers (for STM32) eventually, and it actually ended up taking quite a bit longer than I was expecting
@reeb85873 жыл бұрын
@@MitchDavis2 valid points 👍🏻 im enjoying your videos so far, hope you'll come up with more!
@chadzulu4328Ай бұрын
This is great!
@nathanquattrochi12993 жыл бұрын
1:04 nice
@n-o-i-d4 жыл бұрын
Thank you for this amazing content!
@ThordMoller2 жыл бұрын
This is great! I already learned this stuff in a course at the university a few years ago, but needed a refresher. I always felt that the arduino coding is making things dumber rather than easier. And every time i start working with arduino i feel like im relearning bad habits lol. The easy accessability and price of arduinos is great but why cant we all just learn to code like this?
@sermuns Жыл бұрын
this is amazing! thank you!
@Oshan_Dissanayaka5 ай бұрын
Thank you very much!
@zephsmith34994 жыл бұрын
I understand the niche of starting at the bottom level in understanding the ATMEGA chips and the Arduino environment - looking under the hood to explain registers, machine code, assembly, and C/C+. And learning to bypass the Arduino libraries at times. Kudos. There is value in that. But what is the reason for aiming to eventually transitioning to the STM8? I could see why someone aiming for large scale manufacturing might want to use the cheapest uC which can handle their task, and the ATMEGA line often isn't that. But for a hobbiest, what advantage is there to (eventually) transitioning to another low level uC with similar capabilities, using a different toolchain and ecosystem to learn? Consider by contrast, say, planning transitioning to the STM32 line, which has some advantages in handling some tasks which the ATMEGA cannot. One option in this case would be using the Arduino ecosystem retargeted for the STM32, so reducing the new learning curve once one is familiar with the ATMEGA (eg: using the Blue Pill devices). Anyway, good presentation. If you wish to share the reasoning behind the intended direction of this series, that would be cool.
@zephsmith34994 жыл бұрын
@@MitchDavis2 OK, good luck! It's good to see a different approach, starting from the low level and working up. Of course, the other approaches have their value too, but people differ in how they learn best, and in what they are trying to accomplish. I'm pretty familiar with the basics you are covering (my first microcomputer was an IMSAI 8800 and you could use front panel toggle switches to manually enter one byte at a time of machine code, for the boot code!). But I can well imagine that it would be very useful for some beginners. I'll try to check back later and see how this effort matures and what you do next. Kudos!
@Pnlkmr433 жыл бұрын
Excellent content ie., Oscilloscope waves (high level vs low level port assessing ) 18x faster than high level Thank you
@andrewandrosow47974 ай бұрын
What is this digitalWrite() function for?! SBR PORTA, #0; turn on , CBR PRTA, #0; turn off - there are two base operations. Or in the C language: PORTA |=0x01; PORTA &= 0xFE
@thomashvnmusic2 жыл бұрын
To be honest watching this video made evrything click. For some reason it made me understand microcontroller programming better.
@oz32304 жыл бұрын
Thanks a lot man! was looking for this :D
@hitectenshi7566 Жыл бұрын
This is realy realy good example, love it. Maybe I'll be able to do it now, 6 us static output loop. Thank you :-3
@simpletech201610 ай бұрын
Ultimately the code will be compiled to machine code while uploading. Then why the "bare metal" codes are faster?
@Swordhero111 Жыл бұрын
Perhaps the port version is only faster because you are setting it equal, but in digit write it is probably doing the |= operator to set and &= to unset the bit, thus requiring more instructions.
@faizurrahman2399 Жыл бұрын
Correction: The hardware registers used by the Arduino Uno are located on-chip, separate from both RAM and ROM. These registers are used to control the behavior of the microcontroller, including setting pin directions, configuring timers and interrupts, and controlling various peripherals such as the analog-to-digital converter and serial communication ports.
@bramsmcfadden Жыл бұрын
bro, u r smarter then my lecturer
@zDoubleE2311 ай бұрын
For part around 10:40, you might be able to fool the compiler by including semicolon “;” in your for loop.
@gapguy95643 жыл бұрын
Your explanation and effort is very nice! Also the way you say "delay" is making me feel like you must be playing electric guitar.
@bob-ny6kn3 жыл бұрын
Now, to read those one thousand pages of datasheet and see if I can find anything as useful as this...
@abutaymiyyahlectures3 жыл бұрын
awesome!
@ifeoluwaajiboye19404 ай бұрын
This is super helpful. I am trying to learn this but I am confused with the software which needs to be installed. I own a windows laptop - I have installed WINAVR and AVR DUDE. So i write my code on VS CODE, then I am to use a win-avr to compile it?
@mostafagaberahmed66573 жыл бұрын
thank you . this helps
@emma76942 жыл бұрын
great!
@ajmalashraf79214 жыл бұрын
Thank you its so interesting ...
@zetaconvex19874 жыл бұрын
Very nice. Looks like it will soon be time to ditch the IDE entirely and use something like avr-glibc.
@2ftpmarco Жыл бұрын
thanks !
@iamsparkicus3 жыл бұрын
Great video. Thanks. Actually the sound of your loud typing made me realise how bad mine is! Must learn to type!
@freddiesnijman4 жыл бұрын
Thank you
@eduarddez44162 жыл бұрын
At uni their forcing us to program the Arduino board in C rather than in the Arduino language and I can understand why. Thanks alot for the tutorial
@Fnta_discovery2 жыл бұрын
Hello. often program the microcontrollers. I see bit shift right or left using symbol ">>". why we use it. I am waiting for your response thank you.
@subhashkendole3005 Жыл бұрын
In Attiny402, I want to put a delay of 40 seconds. Please suggest using assembly
@medicallyunexplainedsymptoms11 ай бұрын
It's worth pointing out that writing to the whole port to change one bit is bad programming. The code below is a better approach, albeit with magic numbers. I left them in so it matched the program in the video, but defining bit 5 with a sensible name such as LED_Pin and using 1
@SillySideProjects4 жыл бұрын
Also, any chance you could link the datasheet and other references in the description?
@2OO_OK2 жыл бұрын
Thanks for a very understandable video. Is there a way to enter the port value in binary? IE portb=00100000 instead of portb=32? It would be easier to program multi led blink patterns this way.
@MitchDavis22 жыл бұрын
In Arduino IDE, I’m pretty sure you can write binary if it starts with a capital B. Such as “int i = B11001010”
@manofmesopotamia76023 жыл бұрын
You got another subsicriber ☺️
@Flying-Roro3 ай бұрын
What would be the difference between INPUT and INPUT_PULLUP in plain C?
@testme20264 жыл бұрын
Great one thank you, one question why did you leave PORTB=32 and = 0 before the For loop ?
@gaiuszeno13312 жыл бұрын
Why don't you make i volatile? That should be enough to trick the compiler
@subhashkendole30052 жыл бұрын
In Attiny402, this gives port not declared message. Which files to include ??
@GrandNecro11 ай бұрын
i think if you indicate that the variable is volatile, the compiler won't optimize out the loop. for(volatile unsigned i = 0; i
@whyaretheseathing3 ай бұрын
An int can't represent a number up to a million @11:45? Is an int not an 8-byte value in Arduino land? Typical signed int is 2^31 = ~2.147 billion.
@MitchDavis23 ай бұрын
@@whyaretheseathing arduino uses a 2-byte int. Honestly, most of the time I program using explicit variables, such as “uint16_t” when I want a 2 byte number, and “uint32_t” when I want a 32 bit number. That spares us from the ambiguity of “int”
@whyaretheseathing3 ай бұрын
@@MitchDavis2 Ahh, that's not confusing at all 😅Thanks for clarifying!
@QWin-ir6yq11 ай бұрын
Where are definitions? Will this code even compile?
@trarredbandit97342 жыл бұрын
Can you do ESP32 GPIO port manipulation?
@etleo3811 Жыл бұрын
❤🙌🏾 🎉
@isaacyuki1 Жыл бұрын
How does the microcontroller know, that DDRB as a variable is actually the register DDRB? Is this information somewhere stored?
@fixfaxerify2 жыл бұрын
Another solution might be to declare the loop variable volatile.
@grzesiek1x2 жыл бұрын
so why do we put "32" there I don't get it :/
@mauritzg1 Жыл бұрын
Do you have any examples for the new Arduino Uno R4? ;-)
@IvanEng7472 жыл бұрын
How to adapt this code for esp8266? To win in speed.
@VndNvwYvvSvv2 жыл бұрын
Should have covered or referred to a video on but-masking the registers, but good video.
@shawntaylor95093 жыл бұрын
Can you not use hex values instead of decimal values?
@MitchDavis23 жыл бұрын
You can use whatever you want. When it goes to the compiler, it's just a number. More commonly, you write something like (1>>5), which means "the 5th bit is a 1". I cover bit shifting in a later video.