# Embedded Systems/Programmable Controllers

The original 8086 processor shipped with a number of peripheral chips that each performed different tasks. Among these chips were programmable Interrupt controllers, programmable timers, and programmable I/O chips that could handle many of the tasks of the original computer, to take some of the computational strain off the 8086. In new versions of Intel chips (486, Pentium, etc.) many of the peripheral chips have been integrated into the processor, in an attempt to speed up the entire computer. However, much of the functionality remains, even in today's high-end computer systems.

## Timers

Timers are incredibly useful for performing a number of different operations. For instance, many multi-threaded operating systems operate by setting a timer, and then switching to a different thread every time the timer is triggered. Programmable timer chips can often be programmed to provide a variety of different timing functions, to take the burden off the microprocessor.
Another common application of a timer is to keep track of the time in human units of hours and minutes, and often years, months, and days. Often this real-time clock (RTC) has a battery to keep it running even in systems that are usually plugged into line power. Such a timer can save power in two ways:
* When we want to know what time it is—for example, when a digital camera time-stamps a picture it just took—the system can read it from the real-time clock. Other ways of figuring out the time require more energy.
* When a system needs to do something periodically—for example, measure the outside temperature every 10 seconds, and transmit it wirelessly to an indoor display—the system can turn off power to everything except the real-time clock, and then wait for the clock to wake it up.
You can see some of the 8086 compatible timer chips like 8253/54 also they are the same have three independent timers internally but 8254 can work with higher frequencies and is used to generate interrupt like Memory refresh interrupt, Time of day TOD interrupt and the last one is used to generate the speaker frequencies.
Practically all microcontrollers sold today include integrated timer "peripherals" on the same chip. Most embedded systems either (a) have no external timer chip at all, using only the internal timers, (b) an external real-time clock, or (c) attempt to be PC compatible with a "southbridge" chip that emulates both the 8253-compatible timers and the real-time clock.

## Interrupt Controllers

The original 8086 processor had only a single pin used for signaling an interrupt, so a programmable interrupt controller would handle most of the messy details of calling the interrupt. Also, a programmable interrupt controller could be used to monitor an input port for instance, and triggering an interrupt routine when input is received.

## Direct Memory Access

Since memory read/write operations take longer than other operations for the microprocessor, one should avoid moving large blocks of memory. Luckily, the original 8086 came with a programmable direct memory access controller (DMA) for use in automatically copying and moving segments of memory. DMAs could also be used for implementing memory-mapped I/O, by being programmed to automatically move memory data to and from an output port.
DMA memory copies can also greatly enhance system performance by allowing the CPU to execute code in parallel with a DMA controller automatically performing the memory copy.

## Peripheral Interface Controllers

Peripheral interface controllers take a number of different forms. Each different type of port has a different controller that the microprocessor will interface with to send the output on that port. For instance there are controllers for parallel ports and more modern USB ports. These controllers are used for controlling settings on output such as timing, and setting different modes on the output/input port.

## Further reading

* x86 Assembly/Programmable Interrupt Timer