I will go with coding techniques and algorithms for various functions of a microcontroller. Most of them are interrelated. I will explore them in a certain sequence. This chapter deals with I/O; the most essential portion of an embedded system.
Concepts of I/O
I/O is the shorter version of the term Input/Output. In every programmable device, there is some sort of interface to communicate with the outside world.
Ports & Pins
The total number of pins varies from device to device. For example, ATmega8 has 28 pins, ATmega16 has 40 pins and the smallest one ATTiny15 has 8 pins only. We can't use all the pins for our I/O purposes. Some pins are reserved for some special jobs; for example VCC, GND etc. Different pins of a MCU perform different functions. For our I/O needs, some pins are available in a collective form called PORTS. A port means a collection of Pins. Generally, in an 8 bit MCU, each port consists of 8 pins.
Fig: Cable and Port Analogy |