Lecture#01 Arduino Uno — History
Introduction to IO Port — Port Manipulation
Published in
7 min readJul 3, 2018
Arduino was originally developed in Ivrea, Italy. Arduin of Ivrea was the king of Italy about a thousand years ago and is celebrated in local history.
The Piazza Gioberti hosts a pub named after this famous king, which some say is only named after the road it’s on, the Via Arduino…
Here is this lecture in the video: Lecture # 01 Intro To Arduino
Or in Google Slides:
Video Transcription:
What Is an Arduino?The Arduino Uno was announced on September 25, 2011 at the New York Maker Faire. The model name Uno is Italian for the number one and is intended to correspond with the Uno Punto Zero, or 1.0 release
of the Arduino software. Previous releases, numbered 0001 through 0022 have been considered alpha, or preliminary releases.Over the years, the processor has been upgraded twice from the original ATmega8 with 8KB bytes of program memory, first to the ATmega168 with 16KB of program memory and then to the ATmega328 with 32KB bytes of program memory, while remaining pin compatible.Technically speaking, the term Arduino covers the hardware, software, development team, design philosophy, and esprit de corps of the user community.Arduino was originally developed in Ivrea, Italy. Arduin of Ivrea was the king of Italy about a thousand years ago and is celebrated in local history. The Piazza Gioberti hosts a pub named after this
famous king, which some say is only named after the road it’s on, the Via Arduino.The name Arduino is a masculine Italian name meaning “strong friend.” Being a proper name, Arduino is always capitalized. The model name Uno is stylized in all capitals only in the logo on the PCB.For more on the history and heritage of Arduino, as well as mountains of other fascinating information,
please see the Arduino web site, http://arduino.cc.The Arduino Uno I/O BOARD:When most people think of Arduino, they imagine the small, rectangular (and probably blue) printed circuit board (PCB). This is properly called the I/O Board. The I/O Board is the physically tangible part of the Arduino system.The Arduino I/O Board has traditionally been based on the Atmel AVR ATmega8 and later derivatives. The I/O Board also contains a serial port, power supply circuitry, expansion connectors, and miscellaneous support components.ATmega328 processor:Is an AVR is a programmable microcontroller chip.
ATmega328 processor is ATMEGA328P-PU, the first P being for picoPower technology and the second P meaning plastic DIP - Dual in-line package, which is the type of package encapsulation of this chip. A surface-mount version of the Arduino Uno is available too.The power-supply circuitry:The power-supply circuitry has seen some refinement with extra over-current protection and intelligent power-source selection.Expansion Connectors:The ports follow the physical distribution of the pins on the chip itself.USB TO SERIAL PORT:The serial port is used to communicate. In the development stage of your Arduino project, the communication is between the Arduino and your PC, where you’re writing, compiling, and uploading
your sketch to the I/O Board. In the application (or deployment) phase of your project, when your Arduino is performing its intended purpose, the serial port may continue to communicate with your PC,
if that is part of the plan, or it may communicate with another serial device. The use of the serial port is optional at the application stage, so it may be communicating with nothing at all. If this is the case, the receive (RX) and transmit (TX) pins can be used as general-purpose input/output (I/O) lines.Three general-purpose I/O ports:In AVR-parlance, the ATmega8 family, of which the Arduino Uno’s ATmega328 is a derivative, has three general-purpose I/O ports. On the ATmega8, these ports are named Port B, Port C, and Port D.
Each port can have a maximum of eight I/O pins associated with it.With the purpose to never forget again, mark the arduino name position, below is the A that is the power bus, above B, restart C and D. See?The I/O Board’s expansion connectors allow additional circuitry to be easily connected:One of the buried technical details of the Arduino is the naming and grouping of the I/O pins within the expansion connectors. In Arduino-speak, the pins are simply numbered: D0–D13 for the 14 digital ins and A0–A5 for the 6 analog pins. The digital pins run along the top edge of the board, and the analog
pins are on the bottom edge.This naming convention, although widely adopted and referenced extensively in the Arduino documentation and software, is both misleading and inaccurate. Some of the digital pins provide the
analog outputs (PINS 3,5, 6, 9, 10, 11) but are in reality pulse-width-modulation (PWM) or purely digital outputs. The analog inputs can just as easily be used in exactly the same manner as any of
the other digital pins, either as digital inputs or as digital outputs, but never as analog outputs.Arduino pinoutWe’ll be taking a closer look at the Arduino hardware, and more specifically, the Arduino Uno pinoutEvery one of the general purpose I/O pins on the ATmega328 has an alternate peripheral function, which can be selected in software.
The versatility of the pinout provides many different options such as driving motors, LEDs, reading sensors and more.For example the red pins are all PWM and digital at the same time; This one belongs to the interrupt routine too.Both the Arduino and the AVR naming conventions work quite well for their intended purposes and provide a nice overlapping symmetry to the circuit design.Arduino Multiplexed Pins:The serial port are pins RX and TX. Pin 2 (on the 28-pin DIP)
from the AVR side is called PD0 (I/O Port D, bit 0), RXD (received data input pin) to the USART peripheral, as well as PCINT16 (pin-change interrupt 16). From the Arduino side, it’s called D0 (digital
pin 0) or RX.How much current can I draw from the Arduino's pins?
Basically, there are a number of limiting factors:
The lines from the microcontroller have both an aggregate current limit, and an per-pin limit:In Summary:
The absolute maximum for any single IO pin is 40 milliampere;
The total current from all the IO pins together is 200 milliampere max;AVR Architecture: Interfaces to pins: There are twenty digital I/O pins. They can all be used as traditional three-state digital interfaces. Many pins have additional capabilities, as indicated in the previous slides.
Each Pin directly programable - Program direction; value; pull-ups
Some Pins are special - Analogs vs Digital; Clocks; ResetArduino Pin Circuitry - under the hood.Each port is controlled by three registers, which are also defined variables in the arduino language.The DDR register, determines whether the pin is an INPUT or OUTPUT.The PORT register controls whether the pin is HIGH or LOW, and ...The PIN register reads the state of INPUT pins set to input with pinMode().There are 3 eight-bit ports (B, C and D);
How to use the whole 8 bits of a port? PORT MANIPULATIONS is the answer. Port registers allow for lower-level and faster manipulation of the i/o pins of the microcontroller on an Arduino board. As seen previously the chips used on the Arduino board have three ports:
B (digital pin 8 to 13)
C (analog input pins)
D (digital pins 0 to 7)Each port’s pin are controlled by 8 bits.
The Arduino bitfields are arranged like this in each port;Bit numbering (or sometimes bit endianness) is the convention used to identify the bit positions in a binary number or a container for such a value. The bit number starts with zero and is incremented by one for each subsequent bit position.The least significant bit (LSB) - The LSB is sometimes referred to as the right-most bit, due to the convention in positional notation of writing less significant digits further to the right.The most significant bit (MSB, also called the high-order bit) is the bit position in a binary number having the greatest value;Register DDR, determines if the pin is an INPUT or an OUTPUT (1 Output, 0 Input); this means Directions.Register PORT : controls if the pin is in HIGH or LOW state (1 High, 0 Low ); This means StatesGreat now let's recall some key points of the topic through questions and answers. Here is Question 1:1) Which register is responsible for the pin direction configuration (whether input or output) on Arduino board ?The answer is b) DDRx, which is Data Directions Register.
Good! Now
2) Which register is responsible for the pin state configuration (whether high or low) on Arduino ?The answer is a) PORTx, which is the controls byte if the pin is in HIGH or LOW state (1 High, 0 Low ) . Good!
And the last one...3) Which register do we write in '1' to a bit will result in a toggle in the corresponding bit in the Data Register?The answer is d) PINx, Writing a '1' to PINxn toggles the value of PORTxn, independent on the value of DDRxn. The SBI instruction can be used to toggle one single bit in a port. See datasheet pages 98-99.Summary:
DDRx – Direction register Defines whether a pin is an input (0) or and output (1)
PORTx – Pin output value Writing this register sets value of pin
PINx – Pin input value Reading this “register” returns value of pinThere you have it!
In the next lecture:
Let's dive into the bits and bytes of the arduino.
Do not miss this next event.We’re gonna look at every graph of the atmega 328p datasheet. Bye for now!
References & Credits
Arduino Internals (Technology in Action)
Arduino and Open Source Computer Hardware and Software by Nikola Zlatanov*
* Mr. Nikola Zlatanov spent over 20 years working in the Capital Semiconductor Equipment Industry. His work at Gasonics, Novellus, Lam and KLA-Tencor involved progressing electrical engineering and management roles in disruptive technologies. Nikola received his Undergraduate degree in Electrical Engineering and Computer Systems from Technical University, Sofia, Bulgaria and completed a Graduate Program in Engineering Management at Santa Clara University. He is currently consulting for Fortune 500 companies as well as Startup ventures in Silicon Valley, California.