1. 장치관리자 실행

2. 동작->레거시 하드웨어 추가 클릭

3. C:\Program Files (x86)\Atmel\AVR Tools\usb64\windrvr6.inf 경로의 WinDriver 설치

이후 USB에 AVRISP mkII 연결하면 자동으로 드라이버 설치됨.


http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=82994




'[C-04] ATmega2560' 카테고리의 다른 글

[AVR] Intel Hex File Format  (0) 2010.06.25
uIP-AVR  (0) 2009.11.09
Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
Posted by eoseontaek

'[C-04] ATmega2560' 카테고리의 다른 글

Windows7 64bit에 AVRISP mkII 드라이버 설치  (0) 2011.04.26
uIP-AVR  (0) 2009.11.09
Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
Posted by eoseontaek
2009. 11. 9. 23:59

링크 : http://www.laskater.com/projects/uipAVR.htm


uIP-AVR is a port of Adam Dunkel's uIP - A Free Small TCP/IP Stack - to the Atmel AVR series of microcontrollers.


'[C-04] ATmega2560' 카테고리의 다른 글

Windows7 64bit에 AVRISP mkII 드라이버 설치  (0) 2011.04.26
[AVR] Intel Hex File Format  (0) 2010.06.25
Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
Posted by eoseontaek

Link : http://users.rcn.com/rneswold/avr/index.html


LINUX환경에서 Atmel AVR 컴파일러를 사용할수 있는 환경을 만든다.

여기서는 "/usr/local/avr" 디렉토리에 설치한다.

 

- 파일 구하기

/usr/local/avr 디렉토리를 만들고

필요한 파일들을 아래의 사이트에서 다운받는다.

binutils : ftp://mirrors.rcn.net/pub/sourceware/binutils/releases/
avr-gcc : ftp://gatekeeper.dec.com/pub/GNU/gcc
AVR libc : http://savannah.nongnu.org/download/avr-libc/

avrdude : http://savannah.nongnu.org/projects/avrdude

 

- GNU Binutils 컴파일 및 설치하기

이글을 쓰는 시점에 다운받은 파일은 binutils-2.15.tar.bz2 이다.

tar jxvf binutils-2.15.tar.bz2

cd binutils-2.15

./configure --target=avr --prefix=/usr/local/avr

make

make install

 

- 설치된 유틸들의 path를 설정한다.

PATH=$PATH:/usr/local/avr/bin:/usr/local/avr/avr/bin

 

- AVR-GCC 컴파일 및 설치하기

이글을 쓰는 시점에 다운받은 파일은 gcc-core-3.3.2.tar.bz2 이다.

tar jxvf gcc-core-3.3.2.tar.bz2
cd gcc-3.3.2
./configure --target=avr --prefix=/usr/local/avr --disable-nls --enable-languages=c
make

make install

 

- AVR-LIBC 컴파일 및 설치하기

이글을 쓰는 시점에 다운받은 파일은 avr-libc-1.0.5.tar.bz2 이다.

tar jxvf avr-libc-1.0.5.tar.bz2

cd avr-libc-1.0.5

./configure --prefix=/usr/local/avr

make prefix=/usr/local/avr

make prefix=/usr/local/avr install

 

- AVRDUDE 컴파일 및 설치하기

이글을 쓰는 시점에 다운받은 파일은 avrdude-4.4.0.tar.gz 이다.

tar zxvf avrdude-4.4.0.tar.gz

cd avrdude-4.4.0

./configure --prefix=/usr/local/avr

make

make install

'[C-04] ATmega2560' 카테고리의 다른 글

[AVR] Intel Hex File Format  (0) 2010.06.25
uIP-AVR  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
Megaload 사이트  (0) 2009.10.22
Posted by eoseontaek

AVR PID control에대한 Application note



AVR221: Discrete PID controller 
(10 pages, revision A, updated 05/06)

This application note describes a simple implementation of a discrete Proportional-Integral-Derivative (PID) controller.


'[C-04] ATmega2560' 카테고리의 다른 글

uIP-AVR  (0) 2009.11.09
Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR Timer 계산기  (0) 2009.10.26
Megaload 사이트  (0) 2009.10.22
MegaLoad  (0) 2009.10.22
Posted by eoseontaek

'[C-04] ATmega2560' 카테고리의 다른 글

Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
Megaload 사이트  (0) 2009.10.22
MegaLoad  (0) 2009.10.22
AVR 부트로더  (0) 2009.10.22
Posted by eoseontaek

'[C-04] ATmega2560' 카테고리의 다른 글

AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
MegaLoad  (0) 2009.10.22
AVR 부트로더  (0) 2009.10.22
MegaLoad 3.0b3 (ATmega128용 Bootloader)  (0) 2009.10.22
Posted by eoseontaek
2009. 10. 22. 15:48

http://www.microsyl.com/
MegaLoad

 

History

MegaLoad is a Windows based boot loader for all Atmel ATMega microcontrollers that support the Bootloader function.  MegaLoad is a solution for everybody who wants fast loading (~8k in 3 seconds) and easy software upgrade via MCU RS232 port. 

 

Features Ver : 8.0

puce

Now support device larger than 128k flash

puce

Small Bootloader code. Only 256 words if only flash program is need (512 word if flash & EEPROM)

puce

Auto baud configuration allowing any oscillator setup. 

puce

Only embedded requirement is RS232 connector like a MAX232. 

puce

Communicates at 9600,19200,38400,57600,115200bps on Com1 to 20

puce

Simple Monitor window is available to help you to debug your code 

puce

Checksum everywhere to secure data 

puce

Automatic page retry, if error in flash programming 

puce

Automatic byte retry, if error in EEPROM programming 

puce Manual set & clear DTR,RTS if need.
puce Reset button

 

System Requirements

puce Windows, .NET framework 2.0 runtime
puce RS232
puce ATMega

 

History

V1.0b0 First Release!
V1.1b0
puce Removed a problem of Access violation on some PC
puce Removed a problem with Intel Hex files larger than 64k
puce Check box Bootloader on reset default to true
puce Add ATMega16 bootloader files
V1.2b0
puce Add autobaud rate in each bootloader
puce Add Baudrate selection in Megaload
V2.0b0
puce Fresh new look that give more information on what's going on!
puce Add support for ATMega32,64,128
puce Split Monitor windows in 2 (inchar,outchar)
puce Check if the file to program is still on your hard drive
V2.1b0
puce Add a help file (made by Alex Shepherd [ashepherd@wave.co.nz]) THANKS
puce Correct a rare problem of division by zero
puce Correct a bug in the ATMega128 bootloader for file larger than 65280byte
puce Modify some message to be more clear
puce Correct a timing problem when big hex file and slow PC
V2.2b0
puce Correct a rare problem of no free comport when hyperterminal had been use before...
puce Add support for COM5 &COM6
puce Correct a bug in the ATMega128 bootloader who don't start the app after flashing
V2.3b0
puce Add support for ATMega162 (by Bryan Low)
puce Add option bootload on reset or not
puce Add internal pull up on RX line in each bootloader
V3.0b3
puce Add EEprom programming (byte by byte)
puce Add LockBits programming
puce Support for ATMega8,16,32,64,128,8515,8535,162,169
puce One BootLoader source C file managed by #define's
puce Add support for RS485 half duplex
V3.0b4
puce Correct a miss reported device
puce Change intstall sheild version
puce Change compiler version
puce Update help file
V3.0b5
puce Correct a problem with EEprom programming not check
V3.0b6
puce Correct a problem with App start
V3.0b7
puce Correct a problem with GICR and MCUCR register difference
puce Add support for Mega2313 not (tested)
puce Change #define to be more clear
puce WinApp Ready for Mega 48/88/168
V4.0b2
puce Completely rewritten in C# .NET
puce Add support for Mega2313,48,88,168,165,32506450
puce Add support for Mega 168,3290,6490,406,640,1280,2560
puce Support Com1 to 20
puce Remote reset button
puce Programming only if file has change
V4.0b3
puce Option had been remove due to a lot of problem...
puce Bootloader had changed
V4.0b5
puce Remove some problem at first time start
V5.0b1
puce Remove all registration requirement.
V6.1
puce ReWritten in Visual Studio 2005 .NET
V6.2
puce Communication many time faster with USB to Serial converter
V6.3
puce Put the bootloader files out of the setup
V6.31
puce Bootloader now support MEGA1280, MEGA2560, MEGA1128
V7.0
puce Bootloader smaller & cleanner, support new devices, fit in 256 word for flash only programming
V8.0
puce Now support device larger than 128k flash & work with watchdog enable

 

 

Download

MegaLoad

And

 The bootloader files

------>Take the two files!!!<------

 

 

Nice small tutorial for Megaload from Tony Pattison,  Thanks Tony!

How to use it? (By: Tony Pattison)

 

The source code of the windows application is available for 100$US, in C# .NET or Borland C++ Builder.

For more information please email me at:

s b i s s o n n e t t e  at  microsyl dot c   o  m

Do not cut/past this address, due to the lot of junk I received I had "encrypted" my email address

 

Step 1: Load bootloader code

MegaLoad requires the ATMega to be programmed with the boot loader code first. This can be done with almost any programmer, including the Atmel STK500, AVRISP and PonyProg.  Instructions for PonyProg follow.  All programmers must program the BOOTRST fuses, for the BOOTSZ1 & BOOTSZ0 you must check in the datasheet of your mega to have a boot size of 512byte.

 

  1. Connect your Mega as shown on PonyProg website
  2. Read the fuse bit of your Mega, change the value of BOOTSZ1..0 and  BOOTRST.
  3. Program the new fuse bit setup (don't touch to RSTDISBL you will scrap your ATmega!)
  4. Locate the bootloader ZIP file in the MegaLoad directory.
  5. Extract the entire file from the ZIP file.
  6. Use ICCAVR from www.imagecraft.com to build your hex file
  7. Don't forget to make the good #define for your hardware (Check the source code the info is there)
  8. Program the ATMega*.HEX file
  9. That's it.

 

 

Step 2: Setup MegaLoad

  1. Run the MegaLoad program
  2. Click Open and locate the HEX file to program
  3. Select the COM port that the ATMega is connected to (only COM1-COM19 are supported)
  4. Connect the ATMega to the Windows PC
  5. Reset the ATMega
  6. MegaLoad should see the ATMega reset and will program the ATMega at the speed of light!

The MONITOR button opens up a basic terminal emulator for simple debugging.

The MegaLoad listens on the selected COM port for a handshake signal when the ATMega resets.  If MegaLoad isn't working make sure that the cable is correctly connected.  Use the MONITOR button to verify that communication is working between the ATMega and Windows.


'[C-04] ATmega2560' 카테고리의 다른 글

AVR Timer 계산기  (0) 2009.10.26
Megaload 사이트  (0) 2009.10.22
AVR 부트로더  (0) 2009.10.22
MegaLoad 3.0b3 (ATmega128용 Bootloader)  (0) 2009.10.22
ATmega2560 Bootloader  (0) 2009.10.22
Posted by eoseontaek
2009. 10. 22. 15:43

Link : http://blog.naver.com/yeluh?Redirect=Log&logNo=50018247149




이 부트로더는 http://www.microsyl.com/ 에서 다운받아 수정하여 사용하였으며 사용방법은 다음과 같은 절차대로 하면 무난히 성공할수 있음.

 대략적인 과정은 다음과 같다 bootlader.zip의 압축을 푼후  www.imagecraft.com 사의 ICCAVR(Demo Version도 잘동작함)로 컴파일 한후 ATmega 부트영역에 Write한후 Megaload를 실행한후 Atmega장비를 PC RS-232포트와 연결한후 전원을 넣어 다운로드 종료

 

1. ICCAVR에서 main.c를 수정한다. 수정내용은 사용자 장비에서 사용하는 CPU종류, CPU클록, 통신속도를 선택한다.

        //*****************************************************************************
        // MCU Fequancy
        //*****************************************************************************
        #define XTAL        16000000

        //*****************************************************************************
        // Bootload on UART x
        //*****************************************************************************
        //#define UART        0
        #define UART       1
        //#define UART       2
        //#define UART       3

        //*****************************************************************************
        // BaudRate
        // If you don't specify the baudRate divisor the bootloader
        // will automaticaly be in AutoBaudrate mode
        //*****************************************************************************
       #define BAUDRATE     115200
2.  assembly.s 를 수정한다 사용 CPU에만 1을 적용

        ;*********************************************************
        ; Place a 1 for the processor you want use
        ;*********************************************************

        MEGATYPE8   =  0
        MEGATYPE16  =  0
        MEGATYPE32  =  0
        MEGATYPE64  =  0
        MEGATYPE128 =  1
        MEGATYPE162 =  0
        MEGATYPE169 =  0
        MEGATYPE8515 = 0
        MEGATYPE8535 = 0
        MEGATYPE2313 = 0
        MEGATYPE48   = 0
        MEGATYPE88   = 0
        MEGATYPE168  = 0
        MEGATYPE165  = 0
        MEGATYPE3250 = 0
        MEGATYPE6450 = 0
        MEGATYPE3290 = 0
        MEGATYPE6490 = 0
        MEGATYPE406  = 0
        MEGATYPE640  = 0
        MEGATYPE1280 = 0
        MEGATYPE2560 = 0
        MEGATYPE1128 = 0 

 

3. 컴파일하여 생선된 HEX를 부트영역에 Write하면 OK  Write Option은 BOOTRST fuses,BOOTSZ1 & BOOTSZ2 를 Set 하여 4KByte의 부트로드영역지정과 Reset시 부트로더영역부터 실행할수 있게해 주어야 한다.

 

4. Megaload를 실행하여 다운로드할 HEX파일을 선택한후 PC의 사용포트와 통신속도를 지정한후 PC의 232C와 장비를 연결한다.

 

5. 장비에 전원을 인가하면 다운로딩 완료.

[출처] AVR 부트로더 |작성자 장희웅




'[C-04] ATmega2560' 카테고리의 다른 글

Megaload 사이트  (0) 2009.10.22
MegaLoad  (0) 2009.10.22
MegaLoad 3.0b3 (ATmega128용 Bootloader)  (0) 2009.10.22
ATmega2560 Bootloader  (0) 2009.10.22
ATmega2560 TWI(I2C) Implementatioin  (0) 2009.10.22
Posted by eoseontaek


Link : http://www.avrfreaks.net/index.php?module=Freaks%20Tools&func=viewItem&item_id=446

MegaLoad 3.0b3

Updated: Jan 20, 2005

Toolimage

Description

Windows base bootloader for ATMega8,16,32,64,128,162,169,8515,8535

Now support:
- Flash Programming
- EEprom Programming (now only the byte in the HEX file will be modify)
- Lock Bits Programming

Categories

  • Programming SW
Version Presented by Website Price Rating
3.0b3 (Find Distributor) http://www.microsyl.com Free! Rank: 5
Documents Files
    Supported AVRs Supported Tools
    AVR
    MegaAVR
    TinyAVR

    '[C-04] ATmega2560' 카테고리의 다른 글

    MegaLoad  (0) 2009.10.22
    AVR 부트로더  (0) 2009.10.22
    ATmega2560 Bootloader  (0) 2009.10.22
    ATmega2560 TWI(I2C) Implementatioin  (0) 2009.10.22
    WinAVR에서 printf 함수의 사용 방법  (0) 2009.10.18
    Posted by eoseontaek

    '[C-04] ATmega2560' 카테고리의 다른 글

    AVR 부트로더  (0) 2009.10.22
    MegaLoad 3.0b3 (ATmega128용 Bootloader)  (0) 2009.10.22
    ATmega2560 TWI(I2C) Implementatioin  (0) 2009.10.22
    WinAVR에서 printf 함수의 사용 방법  (0) 2009.10.18
    ATmega2560 SPI Implementation  (0) 2009.10.17
    Posted by eoseontaek

    [참조문서]
    ATMEL application note
    AVR311: Using the TWI module as I2C slave

    AVR315: Using the TWI module as I2C master
     

    '[C-04] ATmega2560' 카테고리의 다른 글

    MegaLoad 3.0b3 (ATmega128용 Bootloader)  (0) 2009.10.22
    ATmega2560 Bootloader  (0) 2009.10.22
    WinAVR에서 printf 함수의 사용 방법  (0) 2009.10.18
    ATmega2560 SPI Implementation  (0) 2009.10.17
    ATmega2560 UART0 implementation  (0) 2009.10.17
    Posted by eoseontaek

    위의 질문을 받고 WinAVR에서 printf 함수를 사용하는 방법에 대하여 조사를 했습니다. 다행히 현재 우리가 사용하는 WinAVR에서는 이 기능을 아주 잘 만들어 놓아서 다른 MCU에서 보다 사용하기가 상당히 편리하게 되어 있네요...
       현재 저는 "AVR ATmega128 마스터" 책의 제2판을 작업하고 있는데 이 내용을 포함시켜야 겠습니다. 우선 아래에 골자를 요약하여 올립니다.

       이에 관련된 내용은 avr-libc Reference Manual의 5.13 Standard IO facilities에 잘 나와 있으며, 헤더 파일 stdio.h의 안에도 자세한 설명이 있고, avrfreaks.com의 AVR GCC 포럼에도 많은 질문과 답변이 있습니다... 이는 avr-libc의 V1.0(AvrEdit 3.6에서 사용하고 있는 것)에서 처음 지원하는 기능으로 보입니다. 그 이전에는 안되는 것으로 이야기되고 있는 것을 보면...
       그런데, 매뉴얼에 보면 이 기능은 아직 안정된 것이 아니기 때문에 앞으로 얼마든지 수정될 수 있으니 주의하라고 되어 있습니다. 하지만, 최근에 avr-libc의 V1.2.0이 나왔는데 이 매뉴얼에도 보면 이 기능은 아직 바뀌지 않고 그대로였습니다. 제가 보기에도 아주 잘 만들어진 기능이라서 수정할 필요가 없어보입니다만...

       WinAVR에서 printf 함수를 사용하는 핵심은 사용자가 임의로 1문자를 출력하는 함수를 만들고 이를 fdevopen() 함수로 인식시켜야 한다는 것입니다. 보통 다른 MCU의 C컴파일러에서는 이 함수로 반드시 putchar()라는 함수를 사용하여야 했는데 여기서는 임의로 이름을 지어도 좋군요.
       fdevopen() 함수는 일반 C언어에서 fopen()에 해당하는 것으로, 파라미터가 3개 있는데 첫번째는 출력장치 함수(STDOUT, STDERR), 두번째는 입력장치 함수(STDIN)를 지정하며, 마지막 파라미터는 사용하지 않으므로 항상 0으로 줍니다.

    (1) 우선 먼저 프로그램의 서두에서 헤더파일 stdio.h를 인클루드시킵니다.

    (2) 이제 printf를 ATmega128의 USART0로 출력하는 것으로 가정하면 당연히 이 직렬포트를 초기화하여야 합니다. 아래 예제에서는 이를 USART0_initialize() 함수로 만들었습니다.

    (3) 다음에는 USART0 에 1문자를 출력하는 함수를 만듭니다. printf 함수는 항상 내부적으로 vprintf 함수를 참조하고 이 vprintf 함수는 항상 STDOUT 장치를 참조하여 이 1문자 출력함수를 사용하게 됩니다. 아래 예제에서는 USART0_putchar() 함수로 만들었습니다. 이 함수의 return 형은 반드시 int로 하고 파라미터는 char 형으로 해야 합니다. 만약, 다른 형으로 하면 에러로 처리됩니다...

    (4) 이제 fdevopen() 함수의 첫번째 파라미터로 1문자 출력함수를 STDOUT 디바이스로 할당합니다. 만약, scanf() 함수로 입력하는 기능이 필요하면 두번째 파라미터에도 1문자 입력함수를 만들어 할당하면 됩니다만 여기서는 생략합니다. 아래 예제에서는 fdevopen(USART0_putchar,0,0)으로 하였습니다.

    (5) printf 함수를 사용합니다. 우리가 알고 있는 모든 %서식이 사용될 수 있습니다.

    (6) 그런데 이 소스를 컴파일할 때는 반드시 printf 함수에 해당하는 라이브러리를 링크시켜주어야 합니다. WinAVR 패키지에 보면 이들 라이브러리 함수가 있습니다. 여기에는 정수까지만 출력할 수 있는 libprintf_min.a가 있고 부동소수점 형식까지 출력할 수 있는 libprintf_flt.a가 있습니다. 정수만 처리하는데 부동소수점 기능까지 포함되면 오브젝트 코드 전체가 쓸데없이 길어지기 때문에 이렇게 한 듯합니다.
       만약 정수 출력만 한다면 이를 컴파일할 때 링커 옵션에 ,-Wl,-u,vfprintf -lprintf_min 을 추가하면 됩니다. 하지만, 아래의 예제에서처럼 부동소수점 포맷을 사용하면 반드시 링커 옵션에 ,-Wl,-u,vfprintf -lprintf_flt -lm 이라고 해주어야 합니다. 이 링커 옵션에서는 컴마 사용에 주의하시고, l은 숫자 1이 아니라 모두 L의 소문자라는 것에 유의하십시오...

       아래의 예제를 실행하면 직렬통신으로 PC의 화면에 메시지와 숫자가 1초 간격으로 증가하면서 출력되는 것을 볼 수 있습니다.

       이 예제에서는 USART0를 사용하였습니다만, 마찬가지 방법으로 USART1로 수정하여 사용할 수도 있죠. 또한, 직렬포트가 아니라 LCD 모듈로 서식지정하여 출력을 내보내는 것으로 쉽게 수정할 수 있다는 것을 짐작하실 수 있겠습니다.
       제가 아직 실험을 해보지는 않았지만 WinAVR에서는 더 놀라운 기능이 가능할 듯합니다. 즉, fdevopen() 함수에서 1문자 출력함수를 임의로 지정할 수 있기 때문에 하나의 프로그램 안에서 수시로 printf에 의하여 출력되는 장치를 변경할 수 있을 듯하다는 것입니다. 다른 C의 경우에는 이 함수가 putchar()로 고정되어 있으므로 불가능하거든요... 그러나, WinAVR에서는 처음에 fdevopen(USART0_putchar,0,0)으로 하면 printf 함수가 USART0로 출력하며, 다시 fclose()로 이 장치를 닫고 fdevopen(USART1_putchar,0,0)라고 하면 이번에는 printf 함수가 USART1으로 출력하고, 이를 다시 LCD 모듈로 출력하도록 또 변경할 수도 있을 것이라는 거죠... 놀랍지 않습니까? 거의 PC 수준이 되는 것이죠...

       어쨌든 궁금하신 분들은 잘 사용하시기 바랍니다.

    /* =========================================================== */
    /*                                Usage of printf Function                                    */
    /* =========================================================== */
    /*               Designed and programmed by Duck-Yong Yoon in 2005.  */

    #include < avr/io.h >
    #include < stdio.h >
    #include "c:\AvrEdit\OK128c\OK128.h"

    void USART0_initialize(void)                      /* initialize USART0 */
    {
      UBRR0H = 0;                                           // 19200 baud
      UBRR0L = 51;
      UCSR0A = 0x00;                                      // asynchronous normal mode
      UCSR0B = 0x18;                                      // Rx/Tx enable, 8 data
      UCSR0C = 0x06;                                      // no parity, 1 stop, 8 data
    }

    int USART0_putchar(char c)                      /* print a character */
    {
      if(c == '\n')                                             // process carriage return
        USART0_putchar('\r');
      loop_until_bit_is_set(UCSR0A,UDRE0);     // Tx ready ?
      UDR0 = c;
      return 0;
    }

    int main(void)
    { unsigned char i = 0;
      double x = 0.0;

      MCU_initialize();                                       // initialize MCU
      Delay_ms(50);                                         // wait for system stabilization
      LCD_initialize();                                        // initialize text LCD module

      LCD_string(0x80,"printf function ");            // display title
      LCD_string(0xC0,"   to USART0    ");

      USART0_initialize();                                 // initialize USART0
      fdevopen(USART0_putchar,0,0);              // STDOUT and STDERR device open

      while(1)
        { printf("This is printf test message !\n");
          printf("Integer number : %3d\n",i);
          printf("Float number : %7.3f\n\n",x);
          i++;
          x += 0.101;
          Beep();
          Delay_ms(1000);
        }
    }

    '[C-04] ATmega2560' 카테고리의 다른 글

    ATmega2560 Bootloader  (0) 2009.10.22
    ATmega2560 TWI(I2C) Implementatioin  (0) 2009.10.22
    ATmega2560 SPI Implementation  (0) 2009.10.17
    ATmega2560 UART0 implementation  (0) 2009.10.17
    WinAVR - interrupt의 SIGNAL과 ISR의 차이점  (0) 2009.10.17
    Posted by eoseontaek

    [참조 문서]

    ATMEL Application Notes





    Posted by eoseontaek

    [참조문서]

    ATmega2560 Datasheet
    ATMEL Application notes
    ATmega2560의 Fuse bit 설정.


    Posted by eoseontaek

    SIGNAL(SIG_OVERFLOW0)

    ISR(SIG_OVERFLOW0)

    이렇게 하면 둘다 똑같다.

     

    하지만 ISR은 20071221rc1버전 부터는 옵션을 붙일 수가 있다.

    여기의 옵션으로는

    ISR_BLOCK,

    ISR_NOBLOCK,

    ISR_NAKED,

    ISR_ALIASOF(target interrupt)

    이렇게 4가지가 존재한다.

    옵션을 붙이는 것은

    ISR(SIG_OVERFLOW0, 옵션)과 같다.

     

    그럼 각 기능에 대해 살펴 보자. ( disassembler창을 통해 확인 해봤다. )

    ISR_BLOCK은 안 붙인것과 동일한 일을 수행한다.

      동일한 일이란

      PUSH    R1 // R1 스택에 저장
      PUSH    R0 // R0 스택에 저장
      IN      R0,0x3F // R0에 SREG 읽음
      PUSH    R0 // R0 스택에 저장 ( SREG 스택에 저장 )
      CLR     R1 // R1 지움 ( R1은 0을 유지하는것을 권장한다. AVR에서 )

      // 여기에 사용되는 레지스터 들을 PUSH 한다.
      // 실제 구문

      // 실제 구문 끝

      // 사용이 끝난 레지스터 들을 다시 POP 한다. (원래 프로그램에 영향이 없도록 PUSH와 POP을 수행함)
      POP     R0 // R0 스택에서 꺼냄 ( SREG 스택에서 꺼냄 )
      OUT     0x3F,R0 // SREG에 R0 저장
      POP     R0 // R0 스택에서 꺼냄
      POP     R1 // R1 스택에서 꺼냄

      RETI // 인터럽트 복귀

      이런 일을 하게 된다. 많다. ㅠㅠ

    그럼 ISR_NOBLOCK은

      ISR_BLOCK의 처음에 SEI가 더 붙는다.

    ISR_NAKED는

      PUSH

      POP

      RETI

      전혀 없는

      실제 구문만 수행한다. 그래서 ISR_NAKED를 사용하면 끝에 RETI를 꼭 붙여야 된다.

      예)

      ISR(SIG_OVERFLOW0, ISR_NAKED)

      {

        PORTD = ~PORTD;

        reti();

      }

      이것의 장점은 코드를 최소화 할 수 있다는 점이다.

    마지막으로 ISR_ALIASOF(target interrupt)은

      target interrupt와 같은 일을 한다고 알려주고 끝난다.

      예)

      ISR(SIG_OVERFLOW0)

      {

        PORTD = ~PORTD;

      }

      ISR(SIG_OVERFLOW1, ISR_ALIASOF(SIG_OVERFLOW0));

      이렇게 하면 타이머1 오버플로어가 타이머0 오버플로어와 같은 구동을 한다.

      좋은 점은 프로그램 공간이 절약된다는 점이다.


    '[C-04] ATmega2560' 카테고리의 다른 글

    ATmega2560 Bootloader  (0) 2009.10.22
    ATmega2560 TWI(I2C) Implementatioin  (0) 2009.10.22
    WinAVR에서 printf 함수의 사용 방법  (0) 2009.10.18
    ATmega2560 SPI Implementation  (0) 2009.10.17
    ATmega2560 UART0 implementation  (0) 2009.10.17
    Posted by eoseontaek
    이전버튼 1 이전버튼