ARDUINO UNO :An Engineering Approach

Posted by

Prerequisite : Digital electronics and Microprocessor background. This blog is intended  to gain maximum knowledge using this low-cost  evaluation board. Highly recommended for fresh engineering graduates who have done any ARDUINO UNO based project. This may help them to face related tricky interview questions. If someone used different device, one should find similar information of that particular device. This is discussed in detail at this video.

ARDUINO UNO : This evaluation board has two micro-controllers as marked below. Smaller one is just for USB-to-Serial communication. You may find board schematic here.

arduno1

This board can be powered via USB connector or external DC power supply.  For external power , The recommended range is 7 to 12 volts. The board Tech spec and documentation is available here .

Where is the MCU design specific information ?

ARDUINO UNO R3 board  has ATmega328-PU as main MCU. As per the ordering information in the device data sheet here,This is 28P3 PDIP package with industrial temp range (-40 to 85), If higher temp range or other package type is needed for custom board, one can select other part# of this device. The data sheet provides information required for part#,data retention,voltage,speed and power budget calculation.

ATmega328P is a 8bit enhanced RISC architecture MCU with 32Kbyte in-build self -programmable flash memory, 1Kbytes EEPROM, 2Kbytes Internal SRAM

arduno2

This MCU has many features such as Watchdog,Timers/Counters,RTC,PWM,ADC,Analog Comparators,USART,SPI,I2C compatible two-wire bus,Power saving modes,Atmel QTouch library support.  The detailed information about MCU and its peripherals is available  here.

Where can I find Instruction Set ? 

Software engineers can refer to Instruction set reference manual  here.

What projects I can design with this MCU ?

Please note that the Arduino Uno board has its own limitation so you may have to design your own board or extension for additional features. There are number of application notes in the Documents section  here . Also contact MCU vendor directly for any question on errata doc, price and longevity of the device.

What projects I can design with Arduino UNO?

You may want to take a look at this before planning to design custom board. This will also give you idea about possible projects with Arduino UNO or other Arduino boards.

Memory:

ATmega328 follows the Harvard Controller Architecture i.e. sperate bus for Program and data memory. Program resides in non-volatile 32-kbyte Flash. Non-volatile data(e.g. long term constant tables) resides in 1-Kbyte EEPROM and volatile data(Dynamic Heap and stack)resides in 2-Kbyte SRAM.  One has to design optimize software to meet these limited memory sizes.

arduno3

The 32-bit Program memory is divided into two parts:

A: Application (start:0x0000 to  bootloader-section-start-1)

B: Bootloader : bootloader-section-start to 0xFFFF

You may find code size related information after compilation  in Arduino IDE or Arduino_Debug.exe . To verify this in latter case , Close Arduino IDE and run Arduino_Debug.exe instead from the Arduino installation folder.

arduno6

The highlighted message above indicates max size of Application(sketch) program space is 32256 i.e. 0x7E00 . So bootloader start address is set at  0x7E00

Where is the bootloader code start address set?

Arduino Uno comes with default bootloader which supports the application programming. You may find bootloader start address ( –section-start in  Makefile) at  following folder :

C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

atmega328: TARGET = atmega328

atmega328: MCU_TARGET = atmega328p

atmega328: CFLAGS += ‘-DLED_START_FLASHES=3’ ‘-DBAUD_RATE=115200’

atmega328: AVR_FREQ = 16000000L

atmega328: LDSECTIONS = -Wl,–section-start=.text=0x7e00 -Wl,–section-start=.version=0x7ffe

atmega328: $(PROGRAM)_atmega328.hex

atmega328: $(PROGRAM)_atmega328.lst

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Arduino_Debug.exe also work as diagnostic tool to resolve any issue in initial stage of Arduino IDE launching itself.

In case you plan to develop custom boot loader, Please refer to this first.

How to find Application specific build information ?

You may configure Arduino IDE to save build specific information in custom folder

Open Arduino IDE->File->Preferences 

arduno4

Close Aurduino IDE to change the file preference.txt. Create one folder to store temporary build data at C:\MyArduino,  Add build.path=C:\MyArduino and change upload.verbose=false in preferences.txt highlighted above.

Open Aurduino IDE , compile your sketch and find *.ELF file in C:\MyAurduino folder

You may use avr-objdump application of Arduino itself or install readelf utility

Assembly dump:  “c:\Program Files (x86)”\Arduino\hardware\tools\avr\bin\avr-objdump -d Scroll.ino.elf >> myAsm.txt

Debug Info dump: “c:\Program Files (x86)”\Arduino\hardware\tools\avr\bin\avr-objdump -g Scroll.ino.elf >> myDebug.txt

Debug Info using readelf utilty: If you have readelf installed from web, You may use that one also

C:\MyArduino>readelf -a Scroll.ino.elf >>readall.txt

arduno5

ELF Header:

Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Class: ELF32

Data: 2’s complement, little endian

Version: 1 (current)

OS/ABI: UNIX – System V

ABI Version: 0

Type: EXEC (Executable file)

Machine: Atmel AVR 8-bit microcontroller

Version: 0x1

Entry point address: 0x0

Note:  You may watch this if any doubt. Please subscribe to this page and YoutubeEmbedkari Channel for any latest update. You may provide feedback to embeddedcareers.ind@gmail.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.