System - Arduino case study

  1. Arduino nano board

    Arduino nano is one of Arduino development boards that based on Atmega328p. In terms of software, the Atmega328p is pre-installed the Arduino bootloader so that users can use the serial interface to upload program, instead of SPI. In terms of hardware, the Arduino nano has 5 main components, an Atmega 328p MCU, an external reset circuit, a voltage regulation component, a USB/serial interface convertor, and an external crystal oscillator.

  2. Arduino DIY

    1. Hardware setup

      In the hardware implementation, the USB/serial convertor and the voltage regulator are elminiated. The circuit is shown below.

      1. Capacitor 1 and cap2: must be the same size, 12-22pF
      2. Quazrt crystal: max 20MHz
      3. Reset poll-up resistor: 10Kohm

      Using internal RC oscillator, the external crystal can be futher eliminated.

      To utilize the internal 8MHz oscillator, the low fuse byte should be set 0xN2. A typical cmd is

      avrdude -p m328p -c stk500v1 -b 19200 -P /dev/ttyUSB0 -U lfuse:w:0xe2:m -U hfuse:w:0xde:m -U efuse:w:0xfd:m

      1. efuse = 0xfd: enable BOD and set the trigger voltage to 2.7 V
      2. hfuse = 0xde: enable external reset, debugWIRE, serial programing, watchdog timer. Not preserving EEPROM during chip erase. And set bootloader parameters.
      3. lfuse = 0xe2: disable dividing 8 and clock output, use start-up time for slowly rising power.
    2. Software setup (burn Arduino bootloader)

      To burn the Arduino bootloader, a ISP programmer is necessary. An Arduino can be used as a ISP programmer. Uploading the program of File->example->ArduinoISP would make the arduino behave like a ISP programmer.

      Upload bootloader via Arduino IDE and an Arduino based programmer.

      In connection, the Arduino Nano based programmer is a SPI master, the target Atmega328p chip is a slave (~SS is the reset pin)

      Master/Arduino Nano ProgrammerSlave/Atmega328p
      SCK (PB5, d13)SCK (pin19)
      MISO (PB4, d12)MISO (pin18)
      MOSI (PB3, d11)MOSI (pin17)
      ~SS (PB2, d10)reset (pin1)

      In arduino IDE, 1). Programmer > Arduino as ISP, 2). Tools > Burn Bootloader

      * To burn Arduino bootloader or use Arduino IDE to program, the external crystal oscillator is needed.