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.
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
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.
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.
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.
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.
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.
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.
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
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?
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
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.
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.
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.
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?
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.
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.
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.
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.
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.
@@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.
@@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?
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
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.
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.
@@JacobSorberMaybe 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
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.
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.
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.
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.
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.
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
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...
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.
exactly the information for msp430 i have been locking for the last 10 years :-)
thanks for the video. Great work getting under the hood. I take so many things for granted with my IDE :)
Yeah, most people do.Glad you enjoyed it.
Dude, thank you so mcuh! Hope to see more content on MSP430 capabilities.
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.
same here, a bridging video would help, but still, a great video of how embedded systems engineers work
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.
I was about to post a comment about that, might as well just post the link to the github link
Great video! This is easily a few weeks worth of material just playing with different options!
Very nice, from an undergrad!👍👍👍
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.
Thanks, Kamesh! Yes, I have more data structure videos planned. Let me know if you have specific requests.
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.
Agreed. I actually stopped using the CC2650 in my research for that reason. It was just too difficult to get clear answers.
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.
Hello, great video!
Can you please recommend some resources(courses/books) to learn this in-depth embedded programming?
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
Great video as usual!!!!
Thanks.
To install arv-gcc on OSX the new commands are:
brew tap osx-cross/avr
brew install avr-gcc
ok
On the university we've got atmega 1284p and to turn on the LED we use this:
#define LED_PIN (1
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?
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
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.
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.
Thanks
awesome video!!! Thank you! I wish you included the source code or a github repo
It's available here. jsorber-youtube-source.herokuapp.com/
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.
The easiest way to install the compiler and debugger for msp430(on debain systems):
apt-get install gcc-msp430
apt-get install mspdebug
Cool. Thanks. Sadly, it's not quite as easy on macOS.
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?
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.
There was mentioned JTAG at 1:54.
Is that possible to describe how JTAG works under the hood (e.g. setting breakpoints)?
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.
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.
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.
OK wrote it after pausing at 10:00 lol
I know. Maybe I should have mentioned that at the beginning of the video. :)
Please make videos on Pointers.
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.
du u know kernel programming
?
I have done some kernel programming, though I haven't done much lately. What did you have in mind?
@@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.
@@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?
@@JacobSorber ok i will be waiting for videos. tools for booth application +kernel .
Could you do a makefile for windows, i have tried but i can't get it to work.
Thanks
A LED, not an. "An" is only for consonants. Great video by the way.
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
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.
PLEASE DO STM32F407VG DISCOVERY BOARD
avrdude: stk500_recv(): programmer is not responding
Have searched many forums but didn't get any working solution. Any ideas?
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.
@@JacobSorberMaybe 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
@@JacobSorber Right, I tested it with another arduino and it works.
@@mihirluthra7762 Embedded systems are fun, aren't they? Glad you got it sorted.
Yep surely are. More when we know what's going under the hood.
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.
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.
The two make links under Related videos don't work.
Thanks for the heads up. That's strange. They used to work. They should work now.
@@JacobSorber Yes, thanks. They work for me now.
i don't know how but the video is not i sync with the audio..
hey can anyone help me implement this on windows
On your last video, you mention youre in africa... Which country are you on?
I was in Botswana. I'm now back in the US.
@@JacobSorber oOh, Great. I'm From South Africal., I just discovered your chanel and I really love it.
@@JacobSorber Any Article that you know off where I can read more about compiling C code for Arduino UNO
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.
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.
8:02: "avrduded -F -V"