embeded/AVR (ATmega,ATtiny)2015. 7. 30. 17:46

이러다가 조만간.. 메인 컴터를 리눅이로 갈아 탈듯 -_-

(게임도 안하는데 머...)



$ sudo apt-get install gcc-avr avr-libc avrdude 

[링크 : http://eiggerc.blogspot.kr/2013/03/ubuntu-avr.html]


올 ㅋ

pi@raspberrypi ~ $ avr-

avr-addr2line   avr-c++filt     avr-gcc-4.7.2   avr-gcov        avr-nm          avr-readelf

avr-ar          avr-cpp         avr-gcc-ar      avr-gprof       avr-objcopy     avr-size

avr-as          avr-g++         avr-gcc-nm      avr-ld          avr-objdump     avr-strings

avr-c++         avr-gcc         avr-gcc-ranlib  avr-man         avr-ranlib      avr-strip 


c++ 예제.파일 갯수가 여러개이니 왜 DDRA나 이런게 없냐고 하지 말자?

ATmega1284P.h

AvrBlinkenLed.cpp

IOPort.h

IOPort.cpp

Led.h

Led.cpp 

[링크 : http://10rem.net/.../gnu-cplusplus-blinkenled-part-1...]


project & makefile

$ avr-c++ -mmcu=atmega128 IOPort.cpp

[링크 : http://www.nongnu.org/avr-libc/user-manual/group__demo__project.html]


avr-gcc 기본 헤더 경로 확인

pi@raspberrypi ~/src/avr $ avr-gcc -print-file-name=include

/usr/lib/gcc/avr/4.7.2/include 

[링크 : http://ubuntuforums.org/showthread.php?t=1014673]


위의 예제는 직접 DDRA나 PORTA 등을 선언해서 쓴것이고

원래는 아래 경로의 io.h 를 끌어오면 알아서 mmcu에 맞춰서 하위 헤더를 끌어오게 된다.

pi@raspberrypi ~/src/avr $ sudo find / -name io.h

/usr/lib/avr/include/avr/io.h 


빌드는 성공! 굽는건 나중에 
pi@raspberrypi ~/src/avr $ make
avr-c++ -mmcu=atmega128 IOPort.cpp AvrBlinkenLed.cpp
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:14:0: warning: "PINA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:135:0: note: this is the location of the previous definition
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:15:0: warning: "DDRA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:138:0: note: this is the location of the previous definition
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:16:0: warning: "PORTA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:141:0: note: this is the location of the previous definition



2009/04/07 - [embeded/AVR (ATmega/ATtiny)] - linux에서 AVR 컴파일하기



'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

키보드 DIY 자료  (0) 2015.09.23
avr-gcc -mmcu 관련 작동 내용  (0) 2015.08.02
USART UBRR error rate  (0) 2015.07.29
avr-libc 8bit AVR C++  (0) 2015.07.28
avr twi / i2c 예제 및 풀업관련  (0) 2015.07.19
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 7. 29. 17:54

표로는 감이 안오는데



[링크 : http://www.atmel.com/images/doc2467.pdf]



파형으로 보니 조금 감이 오는 기분?


[링크 : http://www.robotroom.com/Asynchronous-Serial-Communication-2.html]



[링크 : http://web.engr.oregonstate.edu/~traylor/ece473/lectures/uart.pdf]


심심해서 계산해보니...

56kbps / 16M 에서

8바이트 연속으로 보내면 0.5 비트 가 부족해서 최악의 경우 인식을 못할 수도 있겠으나


아마도 UART로 사용시 start bit를 trigger 삼아 그 이후로

클럭을 맞추는 것으로 추측되니 웬만해서는 문제가 안 될지도..

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 7. 28. 14:40

ㄷㄷㄷ 한번 돌려볼까?


Can I use C++ on the AVR?

Basically yes, C++ is supported (assuming your compiler has been configured and compiled to support it, of course). Source files ending in .cc, .cpp or .C will automatically cause the compiler frontend to invoke the C++ compiler. Alternatively, the C++ compiler could be explicitly called by the name avr-c++.

However, there's currently no support for libstdc++, the standard support library needed for a complete C++ implementation. This imposes a number of restrictions on the C++ programs that can be compiled. Among them are:

Obviously, none of the C++ related standard functions, classes, and template classes are available.

The operators new and delete are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)

Some of the supplied include files are not C++ safe, i. e. they need to be wrapped into

extern"C" { . . . } 

(This could certainly be fixed, too.)

Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0.

Constructors and destructors are supported though, including global ones.

When programming C++ in space- and runtime-sensitive environments like microcontrollers, extra care should be taken to avoid unwanted side effects of the C++ calling conventions like implied copy constructors that could be called upon function invocation etc. These things could easily add up into a considerable amount of time and program memory wasted. Thus, casual inspection of the generated assembler code (using the -S compiler option) seems to be warranted.


[링크 : http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_cplusplus.html]


AVR용 STL ㄷㄷㄷ

[링크 : http://andybrown.me.uk/wk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/]

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 7. 19. 22:25

어드레스 맵 구조 까지 나오는 예제가 있으면 좋으련만...

그나저나 SDA, SCL에 풀업을 꼭 달으라네..


[링크 : http://electronicsdo.tistory.com/entry/I2C-The-I2C-of-ATmega128]

SCL 과 SDA 단자는 오픈 콜렉터 또는 오픈 드레인 방식으로 되어 있어 Wired-AND 기능을 합니다. 이 단자는 외부에 풀업 저항(수 K 오옴) 을 연결해 주어야 합니다.

[링크 : http://cafe.daum.net/_c21_/bbs_search_read?grpid=lH2L&fldid=GSYT&datanum=85]


SDA,SCL핀에 풀업저항을 꼭 달아줍니다.

[링크 : http://openctrl.tistory.com/entry/I2C-TWI]


자체 Pull-Up 저항은

30-50kΩ 정도로 저항치가 좀 높은 편이라서, 실제로 Data 와 Clock 라인에는

4.7kΩ 정도로 따로 Pull-Up 저항을 걸어두는 편이 좋습니다.

[링크 : http://egloos.zum.com/bellona/v/1345440]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

USART UBRR error rate  (0) 2015.07.29
avr-libc 8bit AVR C++  (0) 2015.07.28
atmega128 gpio 인터럽트 데이터시트 내용  (0) 2015.07.18
AVR Studio / AVRdude 연동  (0) 2015.03.12
AVRISP 호환 제품 ?  (0) 2015.03.11
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 7. 18. 22:29


PE4/PE5 는 Output Compate (OC3)

PE6은 Timer/counter 3 clk input(T3)

PE7은 Input Capture (IC)

PD쪽은.. 통신을 쓰면 4개 선을 쓰지 못하니

실질적으로 사용가능한 falling edge / rising edge 탐지는 2개 정도 일려나?


결론은.. 핀하나하나 while로 감지 하지 않으려면...

tie-up해서 잡는 수 밖에 없을 것으로 보이네..






External Interrupts

The External Interrupts are triggered by the INT7:0 pins. Observe that, if enabled, the interrupts will trigger even if the INT7:0 pins are configured as outputs. This feature provides a way of generating a software interrupt. The External Interrupts can be triggered by a falling or rising edge or a low level. This is set up as indicated in the specification for the External Interrupt Control Registers – EICRA (INT3:0) and EICRB (INT7:4). When the external interrupt is enabled and is configured as level triggered, the interrupt will trigger as long as the pin is held low. Note that recognition of falling or rising edge interrupts on INT7:4 requires the presence of an I/O clock, described in “Clock Systems and their Distribution” on page 35. Low level interrupts and the edge interrupt on INT3:0 are detected asynchronously. This implies that these interrupts can be used for waking the part also from sleep modes other than Idle mode. The I/O clock is halted in all sleep modes except Idle mode. Note that if a level triggered interrupt is used for wake-up from Power-down mode, the changed level must be held for some time to wake up the MCU. This makes the MCU less sensitive to noise. The changed level is sampled twice by the Watchdog Oscillator clock. The period of the Watchdog Oscillator is 1µs (nominal) at 5.0V and 25°C. The frequency of the Watchdog Oscillator is voltage dependent as shown in the “Electrical Characteristics” on page 318. The MCU will wake up if the input has the required level during this sampling or if it is held until the end of the start-up time. The start-up time is defined by the SUT fuses as described in “Clock Systems and their Distribution” on page 35. If the level is sampled twice by the Watchdog Oscillator clock but disappears before the end of the start-up time, the MCU will still wake up, but no interrupt will be generated. The required level must be held long enough for the MCU to complete the wake up to trigger the level interrupt.


EICRA와 EICRB는 조금 다르게 설명이 적혀있으니 자세히 읽어 봐야 할 듯..

[링크 : http://www.atmel.com/images/doc2467.pdf]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

avr-libc 8bit AVR C++  (0) 2015.07.28
avr twi / i2c 예제 및 풀업관련  (0) 2015.07.19
AVR Studio / AVRdude 연동  (0) 2015.03.12
AVRISP 호환 제품 ?  (0) 2015.03.11
SED1520 데이터시트 / Page, Line, Column  (0) 2014.03.27
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 3. 12. 20:17

AVR Studio 5에 연결만 해보고

실행은 제대로 안해봄.. -_-a


Title : USBAsp

Command : avrdude.exe

Arguments : -c usbasp -p atmega16 -B12 -U flash:w:$(ProjectDir)Debug\$(ItemFileName).hex


본인이 사용할 칩에 맞춰서 -p 뒤에 칩을 기재해주면 된다.


[링크 : http://www.avrfreaks.net/forum/how-install-usbasp-avr-studio-6]

[링크 : http://www.atmel.com/webdoc/atmelstudio/ch10s05s01.html]

[링크 : http://dthoughts.com/blog/2014/04/09/interfacing-usbasp-programmer-with-atmel-studio/]


GUI 상에는 USBasp는 존재하지 않는다. -_ㅠ

또한 강제로 입력해도 콤보박스로 선택되는거라.. 입력이 되지 않는다.



[링크 : http://sourceforge.net/projects/avrdude-gui/]


이녀석은 싸긴한데..

이걸쓰려면 불편을 감수하고 빌드(AVR Studio) / 플래싱(avrdude.exe) 로 나누어서 해야 할 듯

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2015. 3. 11. 22:03

결론 : AVR studio 4.x 대에서는 기본적으로 호환불가

AVR Studio 5.x 이후에서는 External tools로 avrdude를 연결해서 사용가능 -_-


---

싼거래서 일단 구매하고 해보는데...

생각해보니까 블로그 하는 컴퓨터에는 WinAVR 이나 AVRstudio 가 없잖아? ㅠㅠ

일단 드라이버만 다운로드 받아서 설치!




With WinAVR version 20100110 or older, please use libusb_0.1.12.1

라는 README 파일이 있으니까

버전에 맞추어서

libusb_0.1.12.1 아래에서 깔던가 (WinAVR 2010.01.10 이전 버전)

libusb_1.2.4.0 아래에서 깔면된다.


[링크 : http://itempage3.auction.co.kr/DetailView.aspx?ItemNo=A915268257] 12900원

[링크 : http://www.fischl.de/usbasp/]


---

AVR Studio 4.14 에서 시도해보니.

USB로 되어있는 어떠한 장치도 인식을 하지 못한다 -_-




AVRDUDE를 이용해서 읽어오는 건 된다.

일단.. AVR Studio 5.x 이후 부터 외부 프로그램을 통해 구을수 있으니..

4.X 대에서는 포기해야 할 지도?

[링크 : http://khazama.com/project/programmer/]


+

음.. 펌웨어 바꾸던가 해야하려나?

[링크 : http://www.avrfreaks.net/forum/usbasp-avr-studio-new] AVR studio 4.x

[링크 : http://shannonstrutz.com/engineering/setting-up-usbasp-for-use-with-atmel-studio-6] AVR studio 6

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2014. 3. 27. 23:53
Page 라는 개념이 와닫지 않아서 고민하다가 무릅을 탁!치게 하는 데이터시트 발견 ㅋㅋㅋ
일단 Column는 열에 대한 X축 값이고
Page address와 Line address를 통해 Y축에 대한 값을 설정한다.

폰트 데이터는 아래서 위로 가장 왼쪽 부터 1byte씩 사용 될 것으로 생각되며(물론 높이가 5x8 이런 폰트일 경우)
Page는 이렇게 1개의 데이터 전송에 묶여 사용된다.


'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

AVR Studio / AVRdude 연동  (0) 2015.03.12
AVRISP 호환 제품 ?  (0) 2015.03.11
avr glcd (122x32) 소스  (2) 2014.03.27
ATmega128 핀입력 threshold / hysteresis  (0) 2014.03.24
Atmel AVR 라인트레이서 및 IR 관련 링크  (0) 2014.03.22
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2014. 3. 27. 00:25
될지 안될지는 좀 찾아 봐야 하니 일단
공개된 sed1520 122x32 GLCD 소스를 찾아 보는중 ㅠㅠ

[링크 : http://en.pudn.com/downloads65/sourcecode/embed/detail234623_en.html]
    [링크 : http://read.pudn.com/downloads65/sourcecode/embed/234623/AVREW12A03GLY/sed1520.c__.htm

[링크 : http://sunge.awardspace.com/glcd-sd/]
    [링크 : http://sunge.awardspace.com/glcd-sd/node7.html]
    [링크 : http://sunge.awardspace.com/glcd-sd/node8.html]
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2014. 3. 24. 17:20
Vcc 5V 기준 1.4V ~ 1.9V
Vcc 3V 기준 1.0V ~ 1.3V

넉넉잡고
0~1V(Logical 0)
2~5V(Logical 1)

LM324로 굳이.. 5V까지 끌어 올릴 이유가 없었네.. -_-a



[링크 : http://www.atmel.com/Images/doc2467.pdf] 346p
Posted by 구차니