{"id":363,"date":"2023-06-28T10:50:13","date_gmt":"2023-06-28T10:50:13","guid":{"rendered":"http:\/\/localhost\/embeddedwala\/?p=363"},"modified":"2023-07-27T04:13:15","modified_gmt":"2023-07-27T04:13:15","slug":"what-purpose-does-the-start-up-code-has-in-an-mcu","status":"publish","type":"post","link":"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/what-purpose-does-the-start-up-code-has-in-an-mcu\/","title":{"rendered":"What purpose does the start-up code has in an MCU?"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"363\" class=\"elementor elementor-363\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t\t\t\t<section data-particle_enable=\"false\" data-particle-mobile-disabled=\"false\" class=\"elementor-section elementor-top-section elementor-element elementor-element-47d33e1 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"47d33e1\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f770f76\" data-id=\"f770f76\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<section data-particle_enable=\"false\" data-particle-mobile-disabled=\"false\" class=\"elementor-section elementor-inner-section elementor-element elementor-element-05d97b3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"05d97b3\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-inner-column elementor-element elementor-element-33cc1a4\" data-id=\"33cc1a4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-da9819d elementor-widget elementor-widget-text-editor\" data-id=\"da9819d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Start-Up Code is the soul of an\u00a0<strong>MCU<\/strong>. It is the first-ever code that runs on an MCU right after the\u00a0<strong>Power On Reset (POR)<\/strong>. The Start-Up code triggers the initializing of crucial parts of the MCU needed for booting and the subsequent target application launch.<\/p><p>The start-up code in embedded systems is typically lightweight and is written in assembly language, or a combination of C and assembly. When code is written in assembly language, the developer has greater control and can optimize for speed by carefully selecting specific instructions or instruction types.<\/p><p><strong>NOTE :<\/strong>\u00a0<a title=\"Boot Sequence of an MCU\" href=\"https:\/\/embeddedwala.com\/Blogs\/embeddedsystem\/bootsequenceofarmbasedmcu\" target=\"_blank\" rel=\"noopener\">For more detailed overview of Boot Sequence click on this link<\/a><\/p><p>\u00a0<\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-378\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p>Start-Up Code performs several essential tasks to get the MCU ready to run the target application.<\/p><p><strong>These Tasks include :<\/strong><\/p><ol><li><strong><span data-preserver-spaces=\"true\">Stack Pointer Initialization:\u00a0<\/span><\/strong><span data-preserver-spaces=\"true\">Stack Pointer points to the memory location in\u00a0<strong>RAM<\/strong>\u00a0which will be used by the program to store the function call stacks and the local variables for each function call. Start-Up Code initializes the Stack Pointer with the known Stack location address (The top address of the stack).<\/span><\/li><li><strong><span data-preserver-spaces=\"true\">Data Section Initialization:<\/span><\/strong><span data-preserver-spaces=\"true\">\u00a0Data Section in the memory layout contains the initialized global and static variables. Start-Up code initializes the data Section from the\u00a0<strong>FLASH\/ROM<\/strong>\u00a0or any other location in the memory to the RAM or the memory where code execution will happen.<\/span><\/li><li><strong><span data-preserver-spaces=\"true\">Block Started by symbol (BSS) Initialization:<\/span><\/strong><span data-preserver-spaces=\"true\">\u00a0BSS Section in the memory layout contains uninitialized global and static variables. The Start-Up code initializes the\u00a0<strong>BSS Section<\/strong>\u00a0with zero, to make sure all the variables get some known value.<\/span><\/li><li><strong><span data-preserver-spaces=\"true\">Vector Table Initialization:\u00a0<\/span><\/strong><span data-preserver-spaces=\"true\">The vector table contains the function pointers of the interrupt callback functions. The Initialization Code for the Start-Up sets the\u00a0<strong>Vector table<\/strong>\u00a0location to the value stored in the vector table section of memory, allowing the designated interrupt callback to be executed each time an interrupt is triggered.<\/span><\/li><li><strong><span data-preserver-spaces=\"true\">Configuring the Clock and Debug Setting:\u00a0<\/span><\/strong><span data-preserver-spaces=\"true\">Depending upon the application, the clock setting defers so Start-Up can take care of the default clock settings or even the complete clock settings and ensures the application code runs at the correct speed.The Start-Up code also sets the debug settings required for the\u00a0<strong>MCU<\/strong>\u00a0Platform e.g. enabling\/disabling the\u00a0<strong>JTAG\/SWD<\/strong>\u00a0for debugging, and enabling\/disabling and configuring the\u00a0<strong>UART<\/strong>\u00a0for debug prints.<\/span><\/li><\/ol><p>\u00a0<\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-377\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code.png\" alt=\"\" width=\"1442\" height=\"1766\" \/><\/p><p><span data-preserver-spaces=\"true\">All the start-up code tasks execution is done by the reset handler function.\u00a0<\/span><span data-preserver-spaces=\"true\">After completing all start-up code tasks, the reset handler exits and transfers control to the main() function, beginning execution of the target application.<\/span><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Start-Up Code is the soul of an&nbsp;MCU. It is the first-ever code that runs on&#8230;<\/p>\n","protected":false},"author":1,"featured_media":385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[88,89],"class_list":["post-363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-digital-communication","tag-mcu-start-up-code","tag-reset-handler"],"acf":[],"views":205,"featured_image_urls":{"full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"thumbnail":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",150,101,false],"medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",300,202,false],"medium_large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"1536x1536":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"2048x2048":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"tp-image-grid":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"covernews-slider-full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"covernews-slider-center":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"covernews-featured":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",520,350,false],"covernews-medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",505,340,false],"covernews-medium-square":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",371,250,false],"_nx_notification_thumb":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/start-up-code-has-in-an-MCU-code-banner.png",100,67,false]},"author_info":{"display_name":"embeddedwala","author_link":"https:\/\/embeddedwala.com\/beta\/author\/embeddedwala\/"},"category_info":"<a href=\"https:\/\/embeddedwala.com\/beta\/category\/blogs\/digital-communication\/\" rel=\"category tag\">Digital Communication<\/a>","tag_info":"Digital Communication","comment_count":"0","_links":{"self":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/comments?post=363"}],"version-history":[{"count":13,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/363\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/363\/revisions\/386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media\/385"}],"wp:attachment":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media?parent=363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/categories?post=363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/tags?post=363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}