How to Blink an LED in C (avr, msp430)

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 78

  • @kenwallace6493
    @kenwallace6493 4 роки тому +25

    You are correct! The biggest snag to embedded programming in bare metal is poor documentation. The first thing I look for is the pointer constants to the configuration registers. Next is the labels they pick and the structure so one knows the syntax to manipulate these registers. This information is often scattered or poorly formatted or obscured by levels of abstraction that confuses the "bare metal" level with higher levels. I personally don't think bit definitions are worth it, too many and you still need the spec sheet definition of the register bits for many peripherals. Finally, the Makefile approach where one is setting compiler options/flags is downright scary - I never feel confident that I can get these all right. Keep up the detail on this. Think about a session on ARM microcontrollers in the future (such as the Bluepill). Great stuff.

    • @KangJangkrik
      @KangJangkrik 2 роки тому

      Even today most 3D printers (for hobbyist) are coded with Arduino libraries, because bare metal straight down to dangerous level which makes undefined behavior seldomly happen

  • @laca103
    @laca103 2 роки тому +1

    I've learned more embedded stuff during 60 minutes of your videos, than during a whole semester of my "MCU programming class" as part of my EE Bsc...

  • @grassrootfilms
    @grassrootfilms Рік тому +4

    If you go the AVR path, make sure you go get the Atmel datasheets on the MCU you're working with and read through it some. Things like DDRB seem scary and cryptic until you see in the datasheet that means "Data Direction Register - Port B". Then everything else Jacob explains is like, "Oh, I see!!!" There is a ton of info in those involving the timers and comparators and some of that is just magical with how well it works.

  • @ChristianDeutinger
    @ChristianDeutinger 3 роки тому

    exactly the information for msp430 i have been locking for the last 10 years :-)

  • @g.1100
    @g.1100 4 роки тому +2

    thanks for the video. Great work getting under the hood. I take so many things for granted with my IDE :)

    • @JacobSorber
      @JacobSorber  4 роки тому +1

      Yeah, most people do.Glad you enjoyed it.

  • @lucianopavarotti4715
    @lucianopavarotti4715 4 роки тому +2

    Dude, thank you so mcuh! Hope to see more content on MSP430 capabilities.

  • @sylvestrestalin
    @sylvestrestalin Рік тому +1

    I wish there was one or two more videos between the previous video and this one. I'm having a hard time understanding changing the register's values and what's happening and more about how the compiler and uploader work and their options and what not.

    • @redflags30
      @redflags30 8 місяців тому

      same here, a bridging video would help, but still, a great video of how embedded systems engineers work

  • @ckafrouni
    @ckafrouni 4 роки тому +2

    Hey! Thanks a lot for the video, got me started on an arduino I got as a gift about a year ago!!
    I just wanted to specify the command to install avr-gcc on macs has changed.
    It is now:
    "brew tap osx-cross/avr && brew install avr-gcc"
    Thanks again, looking forward to watch more of your videos.

    • @arturfil
      @arturfil 4 роки тому +1

      I was about to post a comment about that, might as well just post the link to the github link

  • @JustinCromer
    @JustinCromer 3 роки тому

    Great video! This is easily a few weeks worth of material just playing with different options!

  • @khomo12
    @khomo12 7 місяців тому

    Very nice, from an undergrad!👍👍👍

  • @kameswarchembrolu9211
    @kameswarchembrolu9211 4 роки тому +1

    Hi Jacob. I am Kamesh and an active follower of your channel. I am an embedded systems engineer and I really found your videos related to C programming and Data structures very helpful. Can you make more videos of data structures implementations and development in C. Because there aren't many good resources as yours about C.

    • @JacobSorber
      @JacobSorber  4 роки тому

      Thanks, Kamesh! Yes, I have more data structure videos planned. Let me know if you have specific requests.

  • @jawadtahmeed
    @jawadtahmeed 4 роки тому

    I've been working for quite a few time on TI's CC2650 launchpad MCU and man, the documentation and function / register abstraction is like an endless maze, total nightmare !! I've never felt so helpless working with embedded systems before in my life.

    • @JacobSorber
      @JacobSorber  4 роки тому

      Agreed. I actually stopped using the CC2650 in my research for that reason. It was just too difficult to get clear answers.

  • @bastawa
    @bastawa 4 роки тому +1

    I think the bigger snag to embedded programming is using RTOS. You get an extra unknown (RTOS version can work with one specific version of the compiler) etc. If you add an extra library to the equation your build process complexity grows exponentially. I had one project for which I didn't document my toolchain (I wasn't aware of those headaches at that time). One year later it took me around 8 hours to build and upload it again! This was TI Tiva TM4xxxxx. You get an error, nobody had it before, you look the header files they don't have symbols they should have or renamed them etc. I have 3 TI development kits and I haven't been using them for a long time due to build process / flashing firmware problems.

  • @kirillyatsenko5365
    @kirillyatsenko5365 3 роки тому +4

    Hello, great video!
    Can you please recommend some resources(courses/books) to learn this in-depth embedded programming?

  • @MichaelDiedricks
    @MichaelDiedricks 3 роки тому +3

    Thanks for this great video series. I really appreciate the informative content you're putting out here for us all.
    I see you're using VS Code - I was wondering if you use any extensions that assist you in embedded programming?
    Also, do you have a good way of managing header files - by this I mean in the way you might manage dependencies in web development. Is there a good way of doing this, or are you simply downloading the header files from TI and making sure to keep them up to date?
    Cheers

  • @bastawa
    @bastawa 4 роки тому +1

    Great video as usual!!!!

  • @arturfil
    @arturfil 4 роки тому +1

    To install arv-gcc on OSX the new commands are:
    brew tap osx-cross/avr
    brew install avr-gcc

  • @sc5shout
    @sc5shout Рік тому

    On the university we've got atmega 1284p and to turn on the LED we use this:
    #define LED_PIN (1

  • @oliveira_mh
    @oliveira_mh 3 роки тому +2

    Very interesting video, and high quality content.
    I have a doubt. How do you configure vscode to work with avr-gcc? Where did you define the microcontroller you are using for vscode to recognize DDRB?

  • @manofmesopotamia7602
    @manofmesopotamia7602 3 роки тому

    Thanks for your efforts 🙂, I used to work on Arduino, but I need to move to next level, I see Tons of ARM MCUs chips on AliExpress, I wish that I could use Keil Uvision to program any chip, but I dont know how to start, I wish if you could have some tutorial in future on how to read the programming manual and explain them, coding on Uvision and make cool stuff.
    I wish you got my point. Thanks

  • @mihirluthra7762
    @mihirluthra7762 4 роки тому

    The link provided in the description uses a very old version on avr-*. On running those on macOS Catalina, it would say Bad CPU type in executable. To make the things a little simpler I would suggest to use a package manager like macports.

    • @JacobSorber
      @JacobSorber  4 роки тому +1

      Ah, good to know. I haven't upgraded to Catalina yet. I always patch quickly, but hesitate with major OS versions, because each of Apple's upgrades tend to break one of the cross compilers or other tools that I'm using. Yes, macports or homebrew should probably work fine, as an alternative. Thanks.

  • @chakreshjoshi4302
    @chakreshjoshi4302 2 роки тому

    Thanks

  • @nenojay6832
    @nenojay6832 4 роки тому +2

    awesome video!!! Thank you! I wish you included the source code or a github repo

    • @JacobSorber
      @JacobSorber  4 роки тому +2

      It's available here. jsorber-youtube-source.herokuapp.com/

  • @MegaHatef
    @MegaHatef 3 роки тому

    Thanks for the great video!
    CCS provides a neat debugging interface where you can see all registers states, etc.
    Im so curious if we can have such a thing when we are using non-IDE ENV.
    I was wondering if you have any video/plan to create video about that.
    Thanks.

  • @anfield6321
    @anfield6321 3 роки тому

    The easiest way to install the compiler and debugger for msp430(on debain systems):
    apt-get install gcc-msp430
    apt-get install mspdebug

    • @JacobSorber
      @JacobSorber  3 роки тому

      Cool. Thanks. Sadly, it's not quite as easy on macOS.

  • @19thGreenY
    @19thGreenY 4 роки тому +1

    Thanks for the video, its awesome!
    I'm very new to embedded systems but I got to know that C is the common language as of now.
    But there C++ is gaining popularity.
    Can I choose to learn embedded programming in C++ instead of C?

    • @JacobSorber
      @JacobSorber  4 роки тому +5

      Absolutely, just be careful. Make sure you understand what those C++ features are doing for you. Things like classes should be fine. Things like dynamic memory allocation (new) could get you into trouble, especially if you have very little memory. Virtual methods can add some delays, which may or may not be a problem. C++ is just more complicated, and so there are more things that beginning programmers often don't understand that can cause problems that seem like magic.

  • @aabdev
    @aabdev 3 роки тому

    There was mentioned JTAG at 1:54.
    Is that possible to describe how JTAG works under the hood (e.g. setting breakpoints)?

  • @shekharmaela2308
    @shekharmaela2308 4 роки тому +1

    I disagree about IDEs getting in the way.
    I'm right now using Xcode as a GUI to lldb in order to find where I need to modify code to add a new feature.

    • @JacobSorber
      @JacobSorber  4 роки тому +2

      Yeah, sorry if I gave you the wrong IDEa. I'm ok with using IDEs as long as they behave themselves. I think they're problematic when new programmers are learning, because they hide stuff, but I sometimes use them myself, and in certain situations they can definitely simplify things.

  • @mikelemon5109
    @mikelemon5109 4 роки тому +1

    Awesome vid but you make it seem like a childs play learning how to program those MCUs but what if someone starts deving with another MCU type (say Nordic NRF52)
    How'd you approach it what and where should you look for syntax and setting(weird unexpected port lock and watchdog timer register editing) you have to put to make the code go better?
    after all debug won't help at all and that's all knowledge based.

    • @mikelemon5109
      @mikelemon5109 4 роки тому

      OK wrote it after pausing at 10:00 lol

    • @JacobSorber
      @JacobSorber  4 роки тому

      I know. Maybe I should have mentioned that at the beginning of the video. :)

  • @ShreyanNag
    @ShreyanNag 4 роки тому

    Please make videos on Pointers.

    • @JacobSorber
      @JacobSorber  4 роки тому

      I have some older videos on pointers.
      ua-cam.com/video/uT-YLEHwVS4/v-deo.html
      ua-cam.com/video/k6ESk9zafHM/v-deo.html
      ua-cam.com/video/axngwDJ79GY/v-deo.html
      I'm sure I haven't covered everything. Let me know what you think I'm missing.

  • @shivam4428
    @shivam4428 4 роки тому +2

    du u know kernel programming
    ?

    • @JacobSorber
      @JacobSorber  4 роки тому +1

      I have done some kernel programming, though I haven't done much lately. What did you have in mind?

    • @shivam4428
      @shivam4428 4 роки тому +1

      @@JacobSorber please share with us. i am basically going towards device drivers . just started character device driver and has completed ipc and sockets programming. i was looking for valgrid ,found on your channel. now in parellel to kernel development also focusing on memory management tools.

    • @JacobSorber
      @JacobSorber  4 роки тому +4

      @@shivam4428 I'll see what I can do. A kernel dev video would be pretty involved. So, I wouldn't expect it in the next month or two. I'm still not clear on what sort of memory mgmt tools you're interested in. Are these kernel-level tools or application-level?

    • @shivam4428
      @shivam4428 4 роки тому +1

      @@JacobSorber ok i will be waiting for videos. tools for booth application +kernel .

  • @terzerk2165
    @terzerk2165 2 роки тому

    Could you do a makefile for windows, i have tried but i can't get it to work.
    Thanks

  • @konstantinrebrov675
    @konstantinrebrov675 4 роки тому

    A LED, not an. "An" is only for consonants. Great video by the way.

    • @JacobSorber
      @JacobSorber  4 роки тому +9

      Thanks.
      I'm not sure I want to get into grammar debates on the channel, but I disagree. I've heard various opinions on this, and there seems to be some debate online. I prefer using "an" with acronyms that sound like they start with a vowel, like LED or RPG when read. The benefit is that it sounds correct when read it aloud, and it seems to be the most common opinion.
      More reading...
      www.grammar.com/a-vs-an-when-to-use/
      www.shearsoneditorial.com/2013/07/a-or-an-with-abbreviations-it-depends/
      web.archive.org/web/20160916082929/alt-usage-english.org:80/excerpts/fxaanbef.html
      blog.apastyle.org/apastyle/2012/04/using-a-or-an-with-acronyms-and-abbreviations.html

    • @zakiabdinasiromar5434
      @zakiabdinasiromar5434 5 місяців тому

      It's 'an' LED. Reason being the pronunciation. It's pronounced as 'El' then 'ee' then 'D'. First letter is a vowel therefore an used. Spelling wise, 'LED'.
      Why it's that way? I have no idea. It is something we'll have to ask the English.

  • @sakshisingh8167
    @sakshisingh8167 3 роки тому

    PLEASE DO STM32F407VG DISCOVERY BOARD

  • @mihirluthra7762
    @mihirluthra7762 4 роки тому

    avrdude: stk500_recv(): programmer is not responding
    Have searched many forums but didn't get any working solution. Any ideas?

    • @JacobSorber
      @JacobSorber  4 роки тому

      Hard to say from here. Have you tried another Arduino? Maybe a driver issue? Depending on what OS you're using, you can sometimes figure out what's happening by looking at the system logs (syslog or dmesg). If there are any issues recognizing a USB device it often shows up there.

    • @mihirluthra7762
      @mihirluthra7762 4 роки тому

      ​@@JacobSorber​Maybe yes, I should try with another arduino. It doesn't work with arduino IDE either. Although syslog or dmesg have no mentions about such things, Anyways, still a great video as always! Love your channel

    • @mihirluthra7762
      @mihirluthra7762 4 роки тому

      @@JacobSorber Right, I tested it with another arduino and it works.

    • @JacobSorber
      @JacobSorber  4 роки тому

      @@mihirluthra7762 Embedded systems are fun, aren't they? Glad you got it sorted.

    • @mihirluthra7762
      @mihirluthra7762 4 роки тому

      Yep surely are. More when we know what's going under the hood.

  • @kenwallace6493
    @kenwallace6493 4 роки тому

    One more rant and I'll shut up. Embedded microcontrollers are complex devices so managing that complexity is key to more universal use of them and more jobs programming them. Folks (like me) who design the product (e.g. solar inverters) simply cannot divert the time and effort into becoming professional computer programmers just to get that job done. We know the detail functions required and we know microcontrollers have great advantages, we just need a simpler "cookbook" to access them at a low level. Asking a professional programmer to "fix" this complexity usually results in further levels of abstraction with greater risk of not knowing what's really going on. In Power Conversion, one is always a microsecond from disaster so that is not an option.

    • @JacobSorber
      @JacobSorber  4 роки тому

      I know. Especially if you get a professional developer who trained outside of embedded systems. The tension between abstraction (and all the benefits that come with it) and keeping things tight and simple is really common.

  • @aghorn
    @aghorn 4 роки тому

    The two make links under Related videos don't work.

    • @JacobSorber
      @JacobSorber  4 роки тому +1

      Thanks for the heads up. That's strange. They used to work. They should work now.

    • @aghorn
      @aghorn 4 роки тому

      @@JacobSorber Yes, thanks. They work for me now.

  • @yvaneke580
    @yvaneke580 2 роки тому

    i don't know how but the video is not i sync with the audio..

  • @aumpatel2225
    @aumpatel2225 Рік тому

    hey can anyone help me implement this on windows

  • @hendrykhoza4782
    @hendrykhoza4782 4 роки тому

    On your last video, you mention youre in africa... Which country are you on?

    • @JacobSorber
      @JacobSorber  4 роки тому +1

      I was in Botswana. I'm now back in the US.

    • @hendrykhoza4782
      @hendrykhoza4782 4 роки тому

      @@JacobSorber oOh, Great. I'm From South Africal., I just discovered your chanel and I really love it.

    • @hendrykhoza4782
      @hendrykhoza4782 4 роки тому

      @@JacobSorber Any Article that you know off where I can read more about compiling C code for Arduino UNO

  • @henryzhang7243
    @henryzhang7243 4 роки тому

    Jacob, add delay() waits CPU time. This way cannot pass job interview. Not a good example for Blink even all vendors just use this way for demon purpose.

    • @JacobSorber
      @JacobSorber  4 роки тому +4

      I'm not sure I follow. Are you saying that I shouldn't show examples that aren't job-interview grade solutions? I'm going for simplicity here. If it's your first experience with microcontroller programming under the hood, I'm going with the simplest thing that works. I'll show you how to do it with timers and sleep modes in a future video.

  • @ropersonline
    @ropersonline 3 роки тому

    8:02: "avrduded -F -V"