Комментарии:
Very good explenation. c and c++ can look very different, if you do low level programming, and when you do programing in an operating system. Still the same language.
ОтветитьGeeksForGeeks are the masters of clickbait + stupidity.
ОтветитьEverything above Assembly is far away from the Hardware and high level. :) But I give you that.
There is also nothing wrong with high level programming languages, so I don't get the bashing some people do (yea same with those I use arch btw dudes) use the right language to get the job done. If you have a massive 1MB Ram C is just fine.
If you are more constraint and lets say we are talking about 64KB or even less - then you might want to consider something else.
Isn’t embedded C just writing code (C) to some external processor like a microcontroller?
That’s all.
wow a garbage video half of which consists of refuting a made up, chatgpt generated article?
ОтветитьEmbedded C is same as C, the difference is just understanding microprocessor tool chain, data sheet and understanding hardware architectures and a knowledge of electronics. Embedded C is simply the application of C on embedded product development.
ОтветитьI have been wondering what a linker is for years. I would like a to watch a little more information on linkers.
Ответитьyou suck
Ответитьyou can't cross compile Java, that's on of its features [or rather that you don't have to]...
ОтветитьIt's like asking "what is the difference between English/French and legal English/French". Both are the same languages, use the same vocabulary and grammar set, just that in a legal setting, you focus more on certain vocabulary and syntax that are not very common in everyday speech.
ОтветитьOh dear! That website is an great example of the blind leading the blind.
ОтветитьOne question: how can we access a "non memory mapped" register in C?
Nice video though.
I am not sure what linker files are but as the looks of it, it looks like he is using a typedef enum which is inside a struct that is named "MEMORY" and he is using bitfields(since they can't be used with enums that's why it might be added inside a struct) to intialize how many bits that certain enum variable takes.
If that's the case, that would mean I have finally found a purpose of enums.
I need to see more videos about Linker script
ОтветитьI have Turbo C & Borland c++ builder for old school apps - i even have an old Zeos tower 386 that still works - multiple pentium Packard Bell & A few Dells - all win95 or 98 or xp etc.. all work
but here's my problem
- I understood what you were saying and have seen it - such as Macro & function , extern etc...
I used to use Extern function declarations in Quick Basic 4.5 for small microsoft Quick C & MASM microsoft assembler functions i assmbled (object .obj code) and then linked that where used in main module of my programs that made executeables file .exe before everything went
.DLL etc... (which i stopped there in my programming career because of it's complication &the advent of oop and container classes???, etc...)
Long story short i had to eat, support family, i play with all my old toys - but really needed someone like you to guide, direct and inform me -
Thank you for this information.
I'm an industrial electrician - big stuff, motors, MCC, vfd, inumerous field devices - with a good old school foundation in C - i would love for someone to assist me through the door of embedded C - and i'm not talking arduino - something more practical - say Allen Bradley or other -
I'll trade you, my turbo c/c++ disks (original) and Borland stuff for this guidance and teaching - maybe even app design guidance - like what software & where can i get it to write & publish apps??
That sort of thing.....what do you think? Send me an email i'll send u pics of my old software disks & boxes & books -
Wishful thinking right ! Signed - old school boy programmer - love playing with those old c, qb, assembler - wife always asking me - why do you have all these old computers - she just doesnt get it - lol
The syntax of C doesn't change, but rather you need to rethink how you design your code. You're not building an app to execute on an OS, you're creating the firmware to run the entire machine.
ОтветитьIf possible would you please explain linker scripts in details
ОтветитьFrom my perspective the major differences are:
MCUs are generally harvard architecture - so code and constant are stored in flash, and standard RAM is used for variables. Since MCUs tend to be memory constrained you really need to keep constants in the flash memory. Sometimes this involves using macros for constants, and accessing that data using special functions. For example with ATMEL parts, if you use const uint8_t x=0; that will actually be put into dynamic RAM, wasting precious memory.
Since MCUs have little memory, you often cannot dynamically allocate arrays on the stack. They need to be global, or created on the heap using malloc(). This can cause strange intermittent crashes for new programmers.
For any non-trivial code, you'll be using interrupt-driven functions a LOT. You need to write code that can handle this seamlessly and efficiently. This even changes the way you plan out your code - it's inefficient to read from an ADC and wait in a loop for the result. Your code should start the ADC conversion, then carry on doing something else and an interrupt can fire after the ADC has completed so you can read the value immediately.
There are big performance hits on MCUs if you exceed the size of their registers. So using 16bit regs on an 8bit MCU, or 32bit regs on a 16bit etc. So just throwing "int x..." around is generally a bad idea - it's better to specify the type of int you're using.
Due to memory constraints it's also common to use a lot of bitwise flags and registers - 1 8bit value can hold 8 booleans, essentially.
Working out the amount of computing resources you have to maybe reduce power by reducing the clock speed. For instance I recently made some business cards that play tetris, they use an array of LEDs for the 10x20 grid, buttons, and small CR2016 coincells mounted through the card. The coin cell can only put out a few milliamps of current, so the design only ever lights 5 LEDs at a time, but scans through them so fast that the eye doesn't notice any flickering - this display update takes over 90% of the MCU's time, as it is limited to 1mhz, so it doesn't exceed the battery current capacity!
"borland turbo C for archeological sake" -People who LOVE this stuff care about the HISTORY.
Ответитьi have come across many geeksforgeeks articles that are very weird and shows poor quality control
ОтветитьI was learning to code in C for the last 2 years and i was stunned when i saw that embed code.
ОтветитьGcc has different versiones like none-eabi, so I think in the end the compilers avoid using syscall instructions as it knows beforhand that there is no kernel/os
ОтветитьMate, I could never listen to you all day!
ОтветитьBorland Turbo C evolved into Embarcadero C++ Builder and it's absolutely amazing.
ОтветитьThis article sounds like it came from ChatGPT.
There is no difference. If you can do some of the simple stuff you generally never do with C, like setting and clearing bits, you can do this. Trust me, it's not too tough.
The registers for configuring and controlling the device's native peripherals are most often mapped into memory locations. And the programming software the manufacturers supply for free often provide for addressing a register as you would a simple variable using native features of the C language.
So, you essentially operate on bytes and bits in memory with language features that have probably been there forever in plain old C.
What may be tougher is understanding the hardware you choose to use. But even that gets easier. I practically slept with the MCU's reference manual until things made sense.
HELP
ОтветитьDid you know that the first embedded system, the Apollo Guidance Computer, was developed for NASA's Apollo program in the 1960s? It used a custom-built assembly language, but modern embedded systems have come a long way since then! Today, we use Embedded C/C++ to program microcontrollers, enabling devices like IoT gadgets, drones, and even smart appliances. The key difference between regular C/C++ and Embedded C/C++ lies in the system constraints, like memory and processing power, that embedded systems have to work with. This makes writing efficient and optimized code a top priority for Embedded C/C++ developers!
Ответитьas a beginner, im confused to this type of programming style, can it be replaced as a more user friendly code that doesnt involve bit shifting/register? or is it a totally different thing? for example im accustomed to digitalWrite(pin, HIGH) instead of toggling some bit on the register, is it equivalent?
ОтветитьHello sir, I am extremely new with learning C programming, but I want to learn from you because I like your attitude. I am not sure though, that i would be able to learn from you because I am a slow learner. Do you think your class could be for me or do you thank I need some prerequisites to start learning C? Let me know thanks!
ОтветитьEmbedded C is the same C language applied to the Embedded Systems 🙂
ОтветитьFunny, just yesterday I was thinking about Borland. I liked their software. Learned C with TurboC.
ОтветитьThank u .
ОтветитьNice video. I suspect the misconceptions sometimes arise due to lack of experience with, say device drivers, or "larger" computers that have memory-mapped registers. C (not some separate language) is used for that stuff, and for most OS code. Most programmers probably don't run into cross-compilation either.
I have just recently started with hobby microprocessor programming, but have lots of experience with low level stuff on general purpose computers. Systems like the arduino IDE hide a huge amount of detail, which leads to misunderstandings of how the too lchain (including the language) actually works.
more on linker scripts please. a lot more on embedded programming, a project start to finish. walk throughs of were to find and use information for the parts and project. that would be very valuable. and, of course, more than 5 such projects.
ОтветитьC is the world's greatest macro assembler. Embedded C is almost identical.
ОтветитьDEFINITELLY a YES on debugging and testing... Do you perhaps have such a video already??
ОтветитьExcellent video, I love your content they are always educational. I am learning easier stuff than this, JavaScript. But I had a question. RUST is extremely popular now and I hear it can be used for embedded systems as well? Have you used Rust before? In your personal experience do you think Rust is as perfomanent as C or C++?what is your opinion? ThNk you for the excellent content.
ОтветитьIt is hilarious for me when people write programs for IoT with gigabytes of RAM and gigahertz multicore CPU under Linux, and call it "Embedded Programming" :)
ОтветитьAs I mentioned in a different one of your videos, I would love to hear more about linker scripts. If I canʼt do the link by passing a bunch of arguments to gcc or clang, I donʼt know how to do it. I can probably figure it out if that is enough even if some of those arguments are `-Wl,-whatever`, but not if I have to actually invoke ld or gold directly.
ОтветитьHaha right of the bat they say C is used for OS development and “embedded C” is for micro-controllers. Lol what do they think OS code talks to?
Ответитьas cs student from India colleges teach us in turbo c if these guys have windows in the lab if it's Linux then they use text editor to teach us c dammm why they do this I don't know but yeah
Ответитьif they talk about Borland Turbo C++, my guess is that these guys are from Indian subcontinent.
ОтветитьFunny that GCC was only under the "Normal C" while microchip basically only uses forks of GCC for their pic compilers.
ОтветитьNot writing to registers in a desktop micro processor ?!?!?!?
Did those guys never heard of "intrinsics" ?
Microchip compilers for the PIC32 family of micro.controllers are GCC based.
ОтветитьClearly who wrote that sh*t has a hard time understanding the hardware of a micro-controller. Namely, memory mapped I/O, pin direction/digital/analog plus the peculiarities of the peripherals, like SPI, I2C EUSART, PWM, ADC,...
ОтветитьLast time I used "Borland Turbo C" was on top of WinNT 4.0, for cross development for an MS-DOS based platform.
In case you are curious the MS-DOS based platform(s) were Norand/Intermec portable devices, the grand parents of modern tablets.
By that time, 1999, my goto programming tool for desktop development was C++ Builder 3, and some Visual Basic 5 when forced by my co-workers.
Useful for filling up sheets in exams (experienced).
Ответить