After we have compiled our code for the target MCU, the binary image needs to be written to a controller memory prior to execution and debugging. In this section we will look at the varied ways in which this can be accomplished. These days only factory-side programming is done with test sockets, or better yet at the wafer level before a known good die is bonded to a leadframe and encapsulated. Surface-mount parts already rule out easy removal of an MCU for (repeated) programming.
A number of (frequently vendor-specific) options for in-circuit programming exist, distinguished by the peripherals they use and the memories they affect.
So a pristine MCU often needs to be programmed using an external programming adapter. These generally work by setting the pins of the MCU so that it enters programming mode, after which the MCU accepts the data stream containing the...