【正文】
。s budget over 25%.Most microcontrollers at this time had two variants. One had an erasable EPROM program memory, which was significantly more expensive than the PROM variant which was only programmable once. Erasing the EPROM required exposure to ultraviolet light through a transparent quartz lid. Onetime parts could be made in lowercost opaque plastic packages.In 1993, the introduction of EEPROM memory allowed microcontrollers (beginning with the Microchip PIC16x84) to be electrically erased quickly without an expensive package as required for EPROM, allowing both rapid prototyping, and In System Programming. The same year, Atmel introduced the first microcontroller using Flash memory. Other panies rapidly followed suit, with both memory types.Cost has plummeted over time, with the cheapest 8bit microcontrollers being available for under $ in quantity (thousands) in 2009, and some 32bit microcontrollers around $1 for similar quantities.Nowadays microcontrollers are cheap and readily available for hobbyists, with large online munities around certain processors.In the future, MRAM could potentially be used in microcontrollers as it has infinite endurance and its incremental semiconductor wafer process cost is relatively low.VolumesAbout 55% of all CPUs sold in the world are 8bit microcontrollers and microprocessors. According to Semico, over four billion 8bit microcontrollers were sold in 2006.A typical home in a developed country is likely to have only four generalpurpose microprocessors but around three dozen microcontrollers. A typical midrange automobile has as many as 30 or more microcontrollers. They can also be found in many electrical devices such as washing machines, microwave ovens, and telephones.Embedded designA microcontroller can be considered a selfcontained system with a processor, memory and peripherals and can be used as an embedded system.[1] The majority of microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for puter systems. These are called embedded systems. While some embedded systems are very sophisticated, many have minimal requirements for memory and program length, with no operating system, and low software plexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal puter, and may lack human interaction devices of any kind.InterruptsMicrocontrollers must provide real time (predictable, though not necessarily fast) response to events in the embedded system they are controlling. When certain events occur, an interrupt system can signal the processor to suspend processing the current instruction sequence and to begin an interrupt service routine (ISR, or interrupt handler). The ISR will perform any processing required based on the source of the interrupt before returning to the original instruction sequence. Possible interrupt sources are device dependent, and often include events such as an internal timer overflow, pleting an analog to digital conversion, a logic level change on an input such as from a button being pressed, and data received on a munication link. Where power consumption is important as in battery operated devices, interrupts may also wake a microcontroller from a low power sleep state where the processor is halted until required to do something by a peripheral event.[ProgramsMicrocontroller programs must fit in the available onchip program memory, since it would be costly to provide a system with external, expandable, memory. Compilers and assemblers are used to convert highlevel language and assembler language codes into a pact machine code for storage in the microcontroller39。s memory. Depending on the device, the program memory may be permanent, readonly memory that can only be programmed at the factory, or program memory may be fieldalterable flash or erasable readonly memory.[Other microcontroller featuresMicrocontrollers usually contain from several to dozens of general purpose input/output pins (GPIO). GPIO pins are software configurable to either an input or an output state. When GPIO pins are configured to an input state, they are often used to read sensors or external signals. Configured to the output state, GPIO pins can drive external devices such as LEDs or motors.Many embedded systems need to read sensors that produce analog signals. This is the purpose of the analogtodigital converter (ADC). Since processors are built to interpret and process digital data, . 1s and 0s, they are not able to do anything with the analog signals that may be sent to it by a device. So the analog to digital converter is used to convert the ining data into a form that the processor can recognize. A less mon feature on some microcontrollers is a digitaltoanalog converter (DAC) that allows the processor to output analog signals or voltage levels.In addition to the converters, many embedded microprocessors include a variety of timers as well. One of the most mon types of timers is the Programmable Interval Timer (PIT). A PIT may either count down from some value to zero, or up to the capacity of the count register, overflowing to zero. Once it reaches zero, it sends an interrupt to the processor indicating that it has finished counting. This is useful for devices such as thermostats, which periodically test the temperature around them to see if they need to turn the air conditioner on, the heater on, etc.Time Processing Unit (TPU) is a sophisticated timer. In addition to counting down, the TPU can detect input events, generate output events, and perform other useful operations.A dedicated Pulse Width Modulation (PWM) block makes it possible for the CPU to control power converters, resistive loads,