顯示具有 avr 標籤的文章。 顯示所有文章
顯示具有 avr 標籤的文章。 顯示所有文章

【Avr】Atmega8


8-bit with 8K Bytes In-System
ATmega8/ATmega8L http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf

image

【參考】

【AVR】Linux


手邊還沒有機器,先寄一下筆記。

【目的】

  • 建立 Linux 下的編譯環境。

【環境】

  • Ubuntu 10.04

【步驟】

  1. 安裝 toolchain/tools
    $ apt-get install gcc-avr binutils-avr avr-libc
  2. 安裝燒錄軟體
    $ apt-get install avrdude
  3. 範例程式 (hello.c)
    #define F_CPU 1000000UL
    #include <util/delay.h>
    #include <avr/io.h>
    #include <stdio.h>
    
    int main (void)
    {
      printf("Hello AVR\n");
      return (0);
    }
  4. 編譯 
    $ avr-gcc -mmcu=atmega48 -Wall -Os -o hello.o hello.c
  1. 輸出成用來燒錄的 hex 檔
    $ avr-objcopy -j .text -O ihex hello.o hello.hex
  2. 燒錄驗證 (無機器,尚未驗證)
    $ avrdude -p m48 -c usbasp -e -U flash:w:hello.hex

【補充】

  1. Toolchain
      • GCC
        • /usr/bin/avr-gcc
      • Include
        • /usr/lib/avr/include
          • avr/io.h
            利用 ifdef 來決定要帶入的 include file,如 ATmega48 為 iom48.h。
            #ifndef _AVR_IO_H_
            #define _AVR_IO_H_
            
            #include <avr/sfr_defs.h>
            
            #if defined (__AVR_AT94K__)
            
            #elif defined (__AVR_ATmega48__)
            #  include <avr/iom48.h>
            ...
            #endif
          • util/delay.h
            提供現成的 _delay_us()/_delay_ms() 函數,
            F_CPU 值是 1000000UL。
            void
            _delay_ms(double __ms)
            {
              uint16_t __ticks;
              double __tmp = ((F_CPU) / 4e3) * __ms;
              if (__tmp < 1.0)
                __ticks = 1;
              else if (__tmp > 65535)
              {
                //__ticks = requested delay in 1/10 ms
                __ticks = (uint16_t) (__ms * 10.0);
                while(__ticks)
                  {
                    // wait 1/10 ms
                    _delay_loop_2(((F_CPU) / 4e3) / 10);
                    __ticks --;
                  }
                return;
              }
              else
                __ticks = (uint16_t)__tmp;
              _delay_loop_2(__ticks);
            }
            
            void
            _delay_us(double __us)
            {
              uint8_t __ticks;
              double __tmp = ((F_CPU) / 3e6) * __us;
              if (__tmp < 1.0)
                __ticks = 1;
              else if (__tmp > 255)
              {
                _delay_ms(__us / 1000.0);
                return;
              }
              else
                __ticks = (uint8_t)__tmp;
              _delay_loop_1(__ticks);
            }
      • Library
        • /usr/lib/gcc/avr/4.3.4/
  2. (TBD)

【參考】

【AVR】AVR series


 

  1. Basic concept
    1. Software: Env setup(winavr+ave studio4) (20090331)
    2. Hardware: Butterfly
  2. Document Notes
    1. AVR Butterfly Evaluation Kit - User Guide
  3. Application
    1. IrDA
    2. 4 way joystick
  4. OS
    1. Arch

【AVR】IR


先收集資料。

【參考】

  1. [很好DIY] WinLIRC電腦萬用紅外線遙控器
    http://www.mobile01.com/topicdetail.php?f=168&t=124928&p=1
  2. 利用AVR(M16)的输入捕获(ICP)对万能红外线遥控器进行解码
    http://hi.baidu.com/alexin163/blog/item/2e838f11ad0452c1a6ef3f35.html/cmtid/820a61239b196543925807dd
  3. AVR USB Joystick
    http://top.ampbb.net/2009/08/avr-usb-joystick.html

【AVR】Butterfly(TBD)


目前還沒版子,先作筆記。

【環境】

  1. Win7

【軟體】

  • Winavr + avrstudio

【硬體】

【準備工作】

  • com port驗證

【程式碼】

【參考】

【AVR】AvrStudio4


【環境】

  1. Win7

【軟體】

  1. WinAvr http://winavr.sourceforge.net/
  2. AvrStudio http://winavr.sourceforge.net/

【硬體】

  1. AVR Butterfly/ATmega169(目前非必要)
    image

【安裝】

  1. 先安裝 WinAvr http://sourceforge.net/projects/winavr/
  2. 再安裝 AvrStudio http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725
    參考影片檔 http://www.youtube.com/watch?v=MnSWMIRsSQo
  3. 安裝完出現
    1. AVR Battery Studio: 給模擬板用的嗎?
    2. AVR Stduio 4: 官方主要開發軟體。
    3. AVR Tool Help
    4. AVR Wireless Studio: 好像是給 Rf 用的。
    5. AVR Plug-in Mananger

【程式】

  1. 打開AVR Stduio 4
  2. 系統會帶起開新專案,選 AVR GCC,填入 Project name,按 Next。
    image
  3. AVR Simulator 2 | ATmega 169 | Finish
    image 
  4. 建立下面程式碼之後存檔。
    #include <stdio.h>
    int main(void)
    {
     printf("Hello Avr\n");
     return (1);
    }

【編譯】

  1. Build | Rebuild All
    image

【燒錄】

  1. 只先驗證WinAvr/AVR Studio的功能所以這部分先省略。

【參考】

  1. AVR Butterfly 連接測試及第一個程式
    http://blog.xuite.net/harveyhuang/diary/6121490
  2. Mp3 decodeVS1011E Module
    http://www.8052diy.com/
  3. Embedded SD Card/MMC Card
    http://www.freelabs.com/~whitis/sd_card/
  4. AVR Butterfly Mp3
    http://www.brokentoaster.com/butterflymp3/index.html
  5. C Programming for Microcontrollers
    http://www.smileymicros.com/Quick%20Start%20Guide%20-%20The%20Next%20Generation.pdf
  6. Pololu 3pi Robot ("3拍"迷宮與循線機器人學習套件)
    http://www.playrobot.com/robotics/production%20information/3pi%20robot.htm
  7. AVR_MEGA開發板
    http://www.kaise.com.tw/u_system/product/mcu/avrmega/

【問題】

  1. 該如何搭配 AvrLib Procyon AVRlib - C-Language Function Library for Atmel AVR Processors?
  2. 何謂AVR Libc http://www.nongnu.org/avr-libc/,和AvrLib有何不同?
 

Ed32. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com