Improve your Arduino programming skills - Using the ATmega328P registers.

Поделиться
HTML-код
  • Опубликовано: 20 сен 2024
  • Other “Improve your Arduino programming skills” videos:
    • Improve your Arduino p...
    In this video I explain what a register is and how you can use it to further optimize your Arduino code.
    When using Serial.begin() for example the registers are set automatically and there is a lot of code generated to get the serial port to work. A lot of code that you probably don’t need for every project. Watch what happens if you set the registers manually and thereby exclude the unwanted code.
    In a few simple steps a 2632 bytes Arduino example program is reduced in size to 682 bytes. By using Atmel Studio the same functionality can be achieved with only 194 bytes.
    Download the datasheet of the ATmega328P here:
    www.brokking.ne...
    Video about uploading the program via the bootloader:
    • Atmel Studio 7 - Progr...

Комментарии • 174

  • @roidroid
    @roidroid 8 лет назад +77

    Wonderful video. I love how you don't immediately discard the Arduino environment - but instead slowly upgrade it in steps, and no step is itself too far.
    You're doing this series very well.

  • @MrCrystan
    @MrCrystan 8 лет назад +41

    This is the best thing I've seen on the topic. Could never have learned so much in so little time. Kudos!

    • @MrCrystan
      @MrCrystan 8 лет назад +5

      this also helps allot for programming attiny13a of 1k memory and now I can do so much more than just a blink and a sensor.

  • @GGAbi2012
    @GGAbi2012 7 лет назад +15

    Every crucial point is thoroughly thought out and implemented in this excellent video. In addition to that it's even perfectly explained with the help of an oscilloscope, sequentially added code sections for better understanding of "code-upgrades" and in my case what I appreciate most is the cross reference to the datasheet. Keep up the good work, I enjoy all your videos

  • @georgeorwell7607
    @georgeorwell7607 6 лет назад +1

    AWESOME! WOW! This is my second tutorial by Joop Brokking and I am blown away by the clarity, the depth, and the detail, indicating someone with not only deep knowledge of the subject, but also the ability to teach convincingly and effortlessly. kudos

  • @hasithaeranga5589
    @hasithaeranga5589 2 года назад

    perfect teaching style from what we know to what we dont know

  • @dinkarjain7489
    @dinkarjain7489 3 года назад

    The datasheet is the only thing why normal people were reluctant to program controllers, it seems complex and requires a knowledge of what peripherals and registers are. But this video clarified why serious microcontroller projects use the bare coding style and a great programmer would rather dabble in a datasheet than producing a cheap code that will have an "amateur hour" label. This is something that hobbyists should add to their must-watch list to step up their game. Great work pal, keep it up!!

  • @dparson
    @dparson 8 лет назад +5

    Totally loved this tutorial, first time I've seen serial data transfers done with the low level UART registers. I would watch one of these for every chapter of the data sheet :) Thanks a ton for making this!

  • @izzyblackout1090
    @izzyblackout1090 6 лет назад +1

    This reminds me of my days with Microchip PIC. Every single bit has to be set up manually. Thank for the infos. Great tutorial. Best method to optimize programming memory

  • @zxlee1
    @zxlee1 7 лет назад

    Thanks for creating this "improve your Arduino programming skills" series. I like the way you guide viewer step by step to understand all the details that shows the big improvement using Atmel studio.

  • @hrnekbezucha
    @hrnekbezucha 7 лет назад +9

    Sure, optimization. But I had no idea you can make such a significant difference. That's amazing.

    • @TheSehaa
      @TheSehaa 7 лет назад +2

      its the serial.begin and serial.write function. it eats memory

    • @danielday3162
      @danielday3162 7 лет назад +3

      The code for the Arduino IDE is C++ which is an object oriented language. Using C or even a lower level language like the AVR instruction set can greatly impact the size of your code.

  • @TheExplant
    @TheExplant 5 лет назад +1

    Fantastic tutorial, really clear! Using this in my project, it also operates much faster now that I use this method. Before I followed your video, the Arduino couldn't keep up with the clock speed of the device from which I'm taking input, and now I can just about match it. Thanks for sharing your expertise!

  • @DailyWalk365
    @DailyWalk365 6 лет назад

    Nice to know that the "void setup(void) {}" in the Arduino IDE is actually part of the "int main(void){}" function just before the "while (1) { }" loop. Again I found an answer to a question I had using AtmelStudio7. Thank you.

  • @leofranssen
    @leofranssen 3 года назад

    Lekker accentje Joop.
    Dank je wel voor het zo gul delen van je kennis.
    Groet Leo.

  • @Fredovsky
    @Fredovsky 8 лет назад

    Ok, I rarely comment but this is one of the most useful and clear video on code optimization. Thank you for taking the time to make such quality videos !

  • @PiefacePete46
    @PiefacePete46 8 лет назад +53

    Your series really is great! You are taking us into the area of 'dark arts' and switching the lights on. :o)

    • @Joop_Brokking
      @Joop_Brokking  8 лет назад +1

      Thank you for the compliments!

    • @BustersCNCchannel
      @BustersCNCchannel 8 лет назад +1

      Thank you, your videos are excellent. You make it look too easy :)

    • @bmistry5
      @bmistry5 8 лет назад

      Great video!
      How about other UART functions?
      i.e. How to write String using Registers?How to read a character?How to read String?
      Please make one video...really interesting topic!

  • @thanasisathanasi4965
    @thanasisathanasi4965 4 года назад

    I would also say it is a wonderful video. Smooth transition from the Arduino Environment to the machine language environment of atmel studio.. Wooowww. Masterpiece. I wish I had a friend like you !!!

  • @EEBBSamarJain
    @EEBBSamarJain Год назад +1

    Hey there, Great explanation on the topic, I just wanted to ask two things,
    1. How and where to print that variable 'inputs', like do we have something like a serial monitor on atmel where we can print the value 'inputs'?
    2. What should we do when we want to send more than 1 byte of data?

  • @freeelectron8261
    @freeelectron8261 5 лет назад

    Real quality here. Joop knows his stuff and explains it really well.

  • @acertivedude4956
    @acertivedude4956 7 лет назад

    This video and the O-scope one have opened my eyes as to how advanced it is possible to get with arduino project code. Thank you!

  • @Anaeijon
    @Anaeijon 6 лет назад

    Another benefit of using the registers when working with multiple digital I/O pins, is, that it ensures all bits in the register are read/written at the same time.
    For example if you have many different LEDs connected to the Arduino Mega and switch them on and of rapidly, while relying on the persistence of vision (for example when building a LED Matrix or Cube), you need to handle the on/off switching off all pins extremely fast.
    If you are using digitalWrite for each pin, it will basically change one pin after another.
    This takes a high number of instructions (including counter etc.) for switching 8 I/O pins.
    Using the output registers instead on the other hand just uses some simple logic to precalculate the whole register and set all pins at once, by putting the precalculated uint8_t onto the Register.

  • @raymunyaka5409
    @raymunyaka5409 4 года назад

    awesome tutorial on AVR micro controllers using arduino and atmel studio. Thankyou very much. From Kenya.

  • @mirkomueller3412
    @mirkomueller3412 8 лет назад +15

    I wish there would be a possibility to press a "big thumbs up" Button - i definitely would press it. Thank you so much !!!

  • @edexnorth123
    @edexnorth123 6 лет назад +1

    this tutorial right here is far superior than the lecture I had taken at collage. By the way *"don't go a shitty collage."* go make a nice cup of coffe and surf the internet for threasures like this one.

  • @jamest.5001
    @jamest.5001 8 лет назад

    thanks so much for making this video. I am needing to get a arduino to control a DC boost converter . the boost stage for a inverter project for my offgrid home. I don't do computers. I haven't programmed anything since VCRs was common. I have watched many videos. trying to learn how to program arduinos. But your video is the best I have seen so far. it has been a great help. to get my mind wrapped around how this process works. I guess in a week or so if any of your teaching took! when I buy my first arduino. thanks again this video has been a big help.

    • @4.0.4
      @4.0.4 7 лет назад

      James stranger Just wanted to motivate you by saying Chinese clones are just as good. You need to get a driver in Windows but there's a version that is signed (can be downloaded from Microsoft servers, so probably safe). The driver is because the serial to USB converter is a cheaper knockoff, but the microcontroller itself (including its serial capabilities) is the same as genuine Arduino.
      The point in Chinese clones is they cost $2. Having a full bag of Arduinos is empowering! Have a look at sites like AliExpress, eBay, DealExtreme, BangGood... whichever has the right prices/shipping (I used three of these already). Also get some modules! Super fun stuff.

  • @kid-vf4lu
    @kid-vf4lu 8 лет назад

    This is the simplest avr uart tutorial I have seen. Thank you!

  • @rootbeard5449
    @rootbeard5449 8 лет назад +2

    Very informative video! Moving your code to pure C environment frees up so much space!

  • @Walkofsoul
    @Walkofsoul 8 лет назад

    Wow, the difference is huge !

  • @vijaykumarkanchukommala2183
    @vijaykumarkanchukommala2183 5 лет назад

    Good video for new learners to start their experience with AVR microcontrollers

  • @ChathuraJayasundaraIMD
    @ChathuraJayasundaraIMD 6 лет назад

    thumbs up if I learn something???? this is like the most amount of knowledge I got about Arduino in one video!!!! thank you sir!!

  • @sergiocastellani9823
    @sergiocastellani9823 7 лет назад

    Speechless. feel guilty that now i got obsessed with registers and things.... Bravo

  • @zaprodk
    @zaprodk 8 лет назад +2

    Very good explanation. Well done - I'm inspired to go read the datasheet as night time reading now :D

  • @JeanDAVID
    @JeanDAVID 6 лет назад

    Amazing optimization of size at low level of programation

  • @lostname605
    @lostname605 8 лет назад +1

    If you want to practice in setting registers, check out the ds3231 real time clocks. they are cheap and have a great datasheet to get started

  • @kevinowenburress2435
    @kevinowenburress2435 7 лет назад

    if you use the right gpio pins you can read them as a register iirc. then you don't have to poll each gpio pin you can just read them all into a register in one clock cycle. I haven't done benchmarks recently but it is significantly faster than polling each bit.

  • @LearnElectronicsCanada
    @LearnElectronicsCanada 7 лет назад

    Your videos are quite good. It's nice to see someone preaching the transition to Atmel Studio to improve code/size. You really want to mess with everyone's head... show one last transition to ASSEMBLY. I still have nightmares about trying to debug Assembly on a 6809 processor in the 80's. With the tools available now, it's much easier to debug assembly code.

  • @elfkind5590
    @elfkind5590 7 лет назад

    THANKS! Please keep them coming! This is one of the best learning channels.

  • @mcorrive12
    @mcorrive12 7 лет назад

    Fantastic series Joop! Thanks for all your efforts in producing these videos!

  •  8 лет назад +1

    Your videos are great. But you have a great responsibility now, I'll get addicted...and I'm going to need more and more.

  • @adochshanov
    @adochshanov 4 года назад

    Always a great pleasure to go deeper and expand the limits of Arduino IDE. Being absolutely new to atmelstudio I wonder whether the software is free to use?

  • @holdengreene9717
    @holdengreene9717 7 лет назад

    Great vid!. One suggestion, you should increase the font size in the IDE to make it easier to read. Keep up the great work.

  • @vizmohanan
    @vizmohanan 8 лет назад

    Great tutorial ! You just demystified the datasheet and gave me confidence to make use of it. Thanks. :)

  • @HandfulOfTranquility
    @HandfulOfTranquility 7 лет назад

    You are an excellent teacher! I don't understand programming well (I've only piddled around with Arduino a small amount), but you make the concepts easy to understand and apply, more so than other RUclipsrs I've seen.

  • @vipinkarhana4030
    @vipinkarhana4030 6 лет назад

    your video is very helpful and well explained. It shows your deeper understanding. (rarely seen such liked ratio i.e 98%)

  • @photonthief
    @photonthief 8 лет назад +1

    This is a fantastic tutorial Joop! Thank you so much!

  • @FranzStrasse
    @FranzStrasse 8 лет назад

    Absolutely wonderful. I really did learn something and am inspired to use some of your techniques.

  • @photon2724
    @photon2724 6 лет назад +2

    improving our Arduino programming skills?!?!?!?!! im a first year engineering student, and we are immediately given an assessment that requires Atmel. Mind you, we have never even touched the Arduino software before. We just left high school. WHAT DO THEY EXPECT FROM US!!!

    • @masaratech
      @masaratech 6 лет назад

      to be fucking geniuss ???!!!!
      Fuck school and long live RUclips!

    • @martinmartinmartin2996
      @martinmartinmartin2996 6 лет назад +1

      Electronics involve many technologies : optics, lenses, fibre optics, nano-tech, ...Engineering a x100 more!
      Plan for the next 10 yrs
      IMPOSSIBLE to become learned in many technologies ... IMPORTANT to accumulate some idea of 4 or 5 unrelated technologies.
      To learn arduino: read and follow simple RUclips videos . Spend 1/2 hour/day on SIMPLE program explanations. Understand the meaning of 3 to 5 different commands every day , but review the previous commands you learned.
      high school is over ...now its time to Work and Learn !

  • @3dw3dw
    @3dw3dw 7 лет назад

    Always learning so much great material from you.
    Thank you so much Joop!!!

  • @VentoRacing1
    @VentoRacing1 7 лет назад

    Great stuff! You have inspired me to work on my arduino coding.

  • @scottbechtel7915
    @scottbechtel7915 7 лет назад

    Mind blown! Didn't know you could use assembly in the Arduino Studio.

    • @ratchet1freak
      @ratchet1freak 7 лет назад

      Here's something to really blow you mind. It's not assembly. Instead those are really just volatile globals bound to the registers.

  • @freddiesnijman
    @freddiesnijman 8 лет назад

    Thanks Joop, excellent. I also have to go and figure it out,but looking forward to go and study your info.

  • @mandelbro777
    @mandelbro777 4 года назад

    awesome stuff dude. Thank you so much for the time you've invested sharing this knowledge. It is most appreciated.

  • @massimogiardina9138
    @massimogiardina9138 6 лет назад +1

    Thank you soooooo much. I neve4 understood how those registers worked

  • @chickenbonelives
    @chickenbonelives 6 лет назад

    This is so new to me it's really rather intense. +1 internets

  • @niyo7803
    @niyo7803 7 лет назад

    Sir your video are best, I understand use of register .

  • @gideonjonkers2683
    @gideonjonkers2683 4 года назад

    Did you know you dont have to use setup and loop in the arduino ide you can directly code int main with a while loop and it will work and atmels version of delay works in arduino ide aswell.

  • @bdureau1
    @bdureau1 6 лет назад

    very interesting video, can be usefull if your are short of memory. However not really good if you want your code to be portable

  • @Stanh11
    @Stanh11 7 лет назад

    More tutorials like this please !

  • @akshayjha9605
    @akshayjha9605 8 лет назад

    Sir can you please make more videos like this or you can make a complete tutorial series of such programming tutorials because first time fortunately I found this kind of video first time I really came to know where to learn arduino programming and
    improve it more can you please make more videos from programming basics
    Thanks alot :-)

  • @danielbycinskij3685
    @danielbycinskij3685 3 года назад

    Great video!!! What program do you use to read the datasheet?

  • @faisalal-jariry5665
    @faisalal-jariry5665 8 лет назад

    An excellent tutorial , would you please zoom in the IDE and text. It is very small to see. Thanks

  • @yaserbatal6474
    @yaserbatal6474 8 лет назад

    very informative series of videos. Keep the good job

  • @zyxwvutsrqponmlkh
    @zyxwvutsrqponmlkh 7 лет назад

    I have to wonder why the arduino ide and compiler would not compile to the same code as your optimized code.

  • @EMandMORE
    @EMandMORE 7 лет назад

    Thank you for the excellent video, I'm really impressed. Just a little question: considering Arduino IDE lets you program at "low level" as you show in this video, is it really necessary to move to Atmel IDE? Is maybe because Arduino IDE has other problems? (except the setup and loop functions which take some memory)

    • @Joop_Brokking
      @Joop_Brokking  7 лет назад

      No, you don't have to move to Atmel. You should use whatever suits your needs.

  • @abdoo_almyhob184
    @abdoo_almyhob184 5 лет назад

    just use "char x " instead if "byte x " in variable declaration, both are 8 bits size and works exactly the same.

  • @jstro-hobbytech
    @jstro-hobbytech 3 года назад

    I understand what you're saying but how do we put this in practice if we (for simplicity sake) say had a 1602 i2c display showing temp and humidity using a dh11.

  • @meme-hj5rs
    @meme-hj5rs 7 лет назад

    Great explanation
    Keep up the good tutorials

  • @wafikiri_
    @wafikiri_ Год назад

    Not so intimidating a manual as one I had to use once to modify a mainframe for its remote shutdown. I found the desired schematics portion in Volume 76 of 130.

  • @zulfqarali8603
    @zulfqarali8603 6 лет назад

    Hi Joop, could you please share an SPI optimize program example?
    BTW: Greate way to teach.

  • @laureven
    @laureven 4 года назад

    Great video. Thank You but :) If You had smaller font YOu could fit more text on the screen. :) Regards

  • @incxxxx
    @incxxxx 4 года назад

    I do not have in Tools of Atmel Studio any Arduino Bootloader. How you got it?

  • @lw8661
    @lw8661 6 лет назад

    Awesome. THANK YOU!

  • @youreale
    @youreale 7 лет назад

    Amazing content bro! subscribed.

  • @BuildItnow
    @BuildItnow 8 лет назад

    very informative, thank you!

  • @tonyhoff86
    @tonyhoff86 3 года назад

    I am a noooob. So... is the idea here that I would build a program in the IDE and then streamline it later, or should the work really be done at the lower level from the beginning?

  • @__cm__
    @__cm__ 7 лет назад

    wow!! beautifully explained!

  • @glidermike1
    @glidermike1 6 лет назад

    Joop, Thank you for this video that explained a great deal to me. However, I am using the ATmega 2560 processor which has multiple USARTs and I am finding it difficult to apply the same register manipulations described in your video. I know you have moved on to more exciting things, but is there any chance for a video on this processor, or at least some guidance.

  • @erygion
    @erygion 5 лет назад

    New sub here :) great channel, I'll be using many videos for studying.

  • @BubbaCZekLP
    @BubbaCZekLP 8 лет назад

    Great video Joop! Could you do one on faster reading of ADC?

    • @AndersJackson
      @AndersJackson 8 лет назад

      The speed you can read are mostly decide by the ADC you use, not by the programs.
      That said, the program code will be less without the Arduino IDE.

  • @thorbennielsen3845
    @thorbennielsen3845 6 лет назад

    Very good. Can we have more?

  • @makesolareasy
    @makesolareasy 8 лет назад

    Hi Joop Brokking. This is completely off your topic on the video. I have code on different steps controlling 3 relays, that must be controlled for different periods of time. What code do I use to to select certain section of my code, if an input is triggered?

  • @Patillac123
    @Patillac123 8 лет назад

    Awesome video. Awesome name.

  • @teiko142
    @teiko142 6 лет назад +1

    Instant like + sub, great stuff!!

  • @coolwinder
    @coolwinder 7 лет назад

    Very very nice!

  • @micaiaskauss
    @micaiaskauss 3 года назад

    Great vid again

  • @AxelWerner
    @AxelWerner 8 лет назад

    Excelent Topic! Excelent Video!!

  • @douglasthomson2986
    @douglasthomson2986 6 лет назад

    Very good. Thanks Joop

  • @jeanpierredaviau7478
    @jeanpierredaviau7478 4 года назад

    I wonder if there is a book on that for the esp32?

  • @daskasspatzle2396
    @daskasspatzle2396 8 лет назад

    Super explanation, thanks ;-)

  • @BernhardHofmann
    @BernhardHofmann 7 лет назад

    Ninja level unlocked.

  • @randysonnicksen9475
    @randysonnicksen9475 6 лет назад

    Joop, I am wanting to learn how to use a programmer with the arduino uno so that I can debug (monitor variables) without inserting extra print commands which affect the speed of my program. Do you have any experience with this, and how to get started. I can't seem to find an information source that walks through all the steps with good explanation.

    • @Joop_Brokking
      @Joop_Brokking  6 лет назад

      I used the Atmel Ice for one of my videos: ruclips.net/video/o3dcmo-hbQw/видео.html
      Works very intuitive and there are useful videos available for the ICE.

  • @AllanKobelansky
    @AllanKobelansky 7 лет назад

    Well done. Thank you.

  • @coryarnett362
    @coryarnett362 8 лет назад

    Great Video.

  • @bastian9945
    @bastian9945 8 лет назад +1

    one thing bothers me really hard did he really printed the whole datasheet just to show it in the video?

  • @imranaalam
    @imranaalam 5 лет назад

    Excellent saying...
    If you really like to make a donation, remember the amount that you want to donate and give it to somebody who needs it a lot more than I do.
    Matthew 25:40

  • @ddxxbb1
    @ddxxbb1 7 лет назад

    Amazing video !

  • @Artezko1
    @Artezko1 7 лет назад

    Does this make any significant impact on the power consumption or just increasing the available memory?

    • @jmullentech
      @jmullentech 7 лет назад

      Atmel Studio has a profiler built in that can check power consumption but I've never played with it. I'd imagine you'd see a difference but I can't imagine it being anything substantial.

  • @AJB2K3
    @AJB2K3 7 лет назад

    Cool, thanks for this.

  • @snjvkumar292
    @snjvkumar292 6 лет назад

    Thanks for tutorial

  • @AJ-qn9wz
    @AJ-qn9wz 7 лет назад

    Well done!

  • @rutherford16
    @rutherford16 5 лет назад

    The link for datasheet is broken, can you fix it??