AVRマイコンについて

(米)アトメル(Atmel Corporationが開発したマイクロコントローラの総称。RISCベースの8ビットマイクロコントローラの総称。
1996年に開発された。H8やPICの様に、メモリ、タイマ、I/Oなどの周辺ハードウエアをワンチップ化し、インサーキットプログラミング(ISP)も可能であるため、電子工作を行う人の間で人気がある。

・C言語によるプログラミング化可能
・ハーバード・アーキテクチャを採用
・FlashROMを内蔵
・ほぼ、1clockで1命令を実行(クロック周波数≒命令実行数)

などの特徴がある。

本実習では、この中でもATmega32U4という型番のマイクロコントローラを用いて実習を行う。

主な特徴は、下記の通り(英文じゃ)

 Features

●High Performance, Low Power AVR®8-Bit Microcontroller
●Advanced RISC Architecture
– 135 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-Chip 2-cycle Multiplier
●Non-volatile Program and Data Memories
– 16/32K Bytes of In-System Self-Programmable Flash (ATmega16U4/ATmega32U4)
– 1.25/2.5K Bytes Internal SRAM (ATmega16U4/ATmega32U4)
– 512Bytes/1K Bytes Internal EEPROM (ATmega16U4/ATmega32U4)
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/ 100 years at 25°C
– Optional Boot Code Section with Independent Lock Bits
       In-System Programming by On-chip Boot Program
       True Read-While-Write Operation
       All supplied parts are preprogramed with a default USB bootloader
– Programming Lock for Software Security
●JTAG (IEEE std. 1149.1
compliant) Interface
  – Boundary-scan Capabilities A ccording to the JTAG Standard
  – Extensive On-chip Debug Support
  – Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
●USB 2.0 Full-speed/Low Speed Device Module with Interrupt on Transfer Completion
 – Complies fully with Universal Serial Bus Specification Rev 2.0
  – Supports data transfer rates up to 12 Mbit/s and 1.5 Mbit/s
  – Endpoint 0 for Control Transfers: up to 64-bytes
  – 6 Programmable Endpoints with IN or Out Directions and with Bulk, Interrupt or Isochronous Transfers
  – Configurable Endpoints size up to 256 bytes in double bank mode
  – Fully independent 832 bytes USB DPRAM for endpoint memory allocation
  – Suspend/Resume Interrupts
  – CPU Reset possible on USB Bus Reset detection
  – 48 MHz from PLL for Full-speed Bus Operation
  – USB Bus Connection/Disconnection on Microcontroller Request
  – Crystal-less operation for Low Speed mode
●Peripheral Features
  – On-chip PLL for USB and High Speed Timer: 32 up to 96 MHz operation
  – One 8-bit Timer/Counter with Separate Prescaler and Compare Mode
  – Two 16-bit Timer/Counter with Separate Prescaler, Compare- and Capture Mode
  – One 10-bit High-Speed Timer/Counter with PLL (64 MHz) and Compare Mode
  – Four 8-bit PWM Channels
  – Four PWM Channels with Programmable Resolution from 2 to 16 Bits
  – Six PWM Channels for High Speed Operation, with Programmable Resolution from 2 to 11 Bits
  – Output Compare Modulator
  – 12-channels, 10-bit ADC (features Differential Channels with Programmable Gain)
  – Programmable Serial USART with Hardware Flow Control
  – Master/Slave SPI Serial Interface
  – Byte Oriented 2-wire Serial Interface
  – Programmable Watchdog Timer with Separate On-chip Oscillator
  – On-chip Analog Comparator
  – Interrupt and Wake-up on Pin Change
  – On-chip Temperature Sensor
●Special Microcontroller Features
  – Power-on Reset and Programmable Brown-out Detection
  – Internal 8 MHz Calibrated Oscillator
  – Internal clock prescaler & On-the-fly Clock Switching (Int RC / Ext Osc)
  – External and Internal Interrupt Sources
  – Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby,and Extended Standby
●I/O and Packages
  – All I/O combine CMOS outputs and LVTTL inputs
  – 26 Programmable I/O Lines
  – 44-lead TQFP Package, 10x10mm
  – 44-lead QFN Package, 7x7mm
●Operating Voltages
– 2.7 - 5.5V
●Operating temperature
– Industrial (-40°C to +85°C)
●Maximum Frequency
  – 8 MHz at 2.7V - Industrial range
  – 16 MHz at 4.5V - Industrial range

■ 日本語での仕様(一部)


■ ICパッケージの外観とピン配置は、以下の通り(参考までに)

■ マイコンの内部構造(ブロックダイアグラム)

 



 実習で用いるマイコンボード

ストロベリーリナックスという会社が「ダビンチ32U」という名称で販売しているボードを用いる。
外観は、以下の通り。

各ピンの機能は、以下の通り

【注意】

  1. PORTFはJTAG(プログラミングやデバッグを行う機能)と共用になっているため、ユーザが使用する場合は、以下の様な設定が必要。
       MCUCR = 0x80; MCUCR = 0x80; // 必ず2回、行う事
  2. POETEのビット2(PE2)は、ブートローダの起動選択用で、47Kohmでプルアップされているため、プルダウンしたり、GND間にデバイスを接続したりしない事。(誤動作の原因となる)。
  3. 本ボードはデフォルトでは、クロックが1MHz動作となっている。最大スピードである16MHzに設定したい場合は、以下のプログラムを実行する事。
    CLKPR = 0x80; CLKPR = 0;
ボードの回路図

Davinci32Uの詳細はこちら。
 


電源の接続について

 マイコンボードに電源を供給する方法は2つある。

  • USBケーブルによる
  • 電池からの供給 (3~5V程度)

 両方を同時に使う事は、決して出来ない事に注意!! 最悪の場合、マイコンボードはおろか、パソコンを破壊する危険がある。(必ず片方だけの接続にすること)


  USBケーブルから電顕供給を行う場合は、下図の様に、USBケーブルをコネクタに挿入する。正常に接続されれば、基板上のLEDが点灯する。

 この状態では、電源はUSBケーブルを介して、パソコンから供給される。また、基板上の+5V端子から、他の回路に電源を供給する事も出来る。この時は+5VとGND(-)にそれぞれ接続する事。

 電池から電源を供給する場合は、下図の様に電池のプラス側(赤い導線)を+5Vに、マイナス側(黒い導線)をGNDに接続する。
 間違っても逆向きに接続しないように。(逆向きに接続すると、ほぼ確実にマイコンを破壊する)

【注意】
 電池ボックスの取り扱いで、多くの事故が発生している。下図の様に、電池ボックスの導線の長さが同じであるため、気付かないうちに、導線がショートしてしまっている事がある。このような状態になると、導線や電池・電池ボックスが加熱・発煙(最悪、発火や破裂)などの事故を起こす。実際、起きている)
 なので、十分注意して取り扱う事。また、実習終了後は、事故防止のため、電池は必ず返却する事。

最終更新:2015年07月16日 10:49