What is Super Loop in Embedded C programming language?
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- R: eval(parse()) error message: cannot ope
- Index of single bit in long integer (in C) [duplic
This refers to the eternal loop usually located in
main()
of a "bare metal" system (no OS), since such systems can never return from main. A typical bare metal embedded system looks like this:Super loop is an infinite loop which is suitable only in embedded c programming because there you have to run your code for very very long time and wants explicitly terminate when the behavior is change for your robot or whatever. Superloop be like
MCU is device which runs continuously or better, it executes instructions when power is on (in general).
So while loop is here to force MCU to do something, even if loop is empty, it will just circle around.
But it must do something as it is not the same as PC program where you have
return
at the end of main function.If you wouldn't have super loop then MCU can get instruction from FLASH/RAM (whatever..) and do something stupid things as MCU don't know what it is executing. It just executes code you provide him.
By using super loop, you guarantee MCU won't just uncontrollable execute some instructions and maybe go to fail-safe area. Of course this can happen even if you have super loop but this is other topic.