embeded/arduino(genuino)2016. 3. 30. 16:31

머 대단한건 아니고.. 그냥

#include <avr/io.h> 

추가하면 된다.

+

2016.03.31

기본적으로 추가되어 있어서 굳이 include 안해도 된다

+


AVR-GCC: "C:\path-to-arduino\hardware\tools\avr\bin"

GNU make "C:\path-to-arduino\hardware\tools\avr\utils\bin"

AVR Header files "C:\path-to-arduino\hardware\tools\avr\avr\include"

AVRDude "C:\path-to-arduino\hardware\tools\avr\bin"

[링크 : http://playground.arduino.cc/Code/Eclipse]


그나저나.. atmega128이랑 비슷할줄 알았는데.. 헤더를 보니 완전 딴판이네..


#include <avr/io.h>

void setup() {  // put your setup code here, to run once:  Serial.begin(115200); } void loop() {  // put your main code here, to run repeatedly:  char str[10];  sprintf(str, "%04X",MCUCR);  Serial.println(str); } 


PUD 값 보려니.. 얘는 0x000으로 나오는거 봐서는

PUD는 기본적으로 0이니까.. pull up disable 이 false

즉, pull up은 enable 되어 있는 것 같은데..



음.. 값이 끌려 다니게 하려면

pud 기본값에, ddr input 설정에, 포트에 값을 입력임에도 불구하고 high로 놔주어야 하는건가?

tri-state는 쇼트 안나게 저항을 퐉! 올려주는거라고 하니.. 통신이 안될테고

결론은 DDR=0; PORT=1; 해야 하려나?



[링크 : http://www.atmel.com/...328-328p_datasheet_complete.pdf]

'embeded > arduino(genuino)' 카테고리의 다른 글

ADXL345 소스 분석 및 아두이노 용으로 변환  (0) 2016.03.30
아두이노 나노 pinout / atmega328p  (0) 2016.03.30
아두이노 / avr bootloader  (0) 2016.03.30
arduino i2c 예제  (0) 2016.03.30
아두이노 on ubuntu 15.10  (0) 2016.03.28
Posted by 구차니
embeded/arduino(genuino)2016. 3. 30. 15:17

예전에 적었던 건데.. 한번쯤은 올려 봐야겟지?

아무튼 부트로더를 올릴려면 ISP 프로그래머가 반드시 필요 하다고 한다.


Burning the Bootloader

To burn the bootloader, you'll need to buy an AVR-ISP (in-system programmer), USBtinyISP or build a ParallelProgrammer. The programmer should be connected to the ICSP pins (the 2 by 3 pin header) - make sure you plug it in the right way. The board must be powered by an external power supply or the USB port.

[링크 : https://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader]

[링크 : https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/bootloaders]


Self Programming

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


Serial Bootloader User Guide

[링크 : http://www.atmel.com/images/...serial-bootloader-user-guide_application-note.pdf]

'embeded > arduino(genuino)' 카테고리의 다른 글

아두이노 나노 pinout / atmega328p  (0) 2016.03.30
아두이노 avr 헤더사용하기 / PUD  (0) 2016.03.30
arduino i2c 예제  (0) 2016.03.30
아두이노 on ubuntu 15.10  (0) 2016.03.28
아두이노 빌드 프로세스 & c/cpp  (0) 2016.03.28
Posted by 구차니
embeded/arduino(genuino)2016. 3. 30. 13:58

마침.. 아두이노 nano 2개가 있으니 해볼까?

i2c는 버스라서 동일한 라인에 선을 연결해주면 끝(SCL/SDA)


[링크 : https://www.arduino.cc/en/Tutorial/MasterReader]

Posted by 구차니
embeded/arduino(genuino)2016. 3. 28. 20:04

시리얼 포트 쓰려면 dialout 그룹에 추가해야 하니 추가해주세열?



윈도우용으로 받는 신버전 보다 낮은지 먼가 메뉴가 다르다.

1.6.8 인거 같은데.. 리눅스 용은 버전이 왜 이모양이야? ㄷㄷ


'embeded > arduino(genuino)' 카테고리의 다른 글

아두이노 / avr bootloader  (0) 2016.03.30
arduino i2c 예제  (0) 2016.03.30
아두이노 빌드 프로세스 & c/cpp  (0) 2016.03.28
아두이노 나노 - LED 블링크 예제  (0) 2016.03.27
아두이노 나노 - 시리얼 테스트  (3) 2016.03.27
Posted by 구차니
embeded/arduino(genuino)2016. 3. 28. 11:17


c/cpp 지원함


Can I program the Arduino board in C? 

In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs supported by avr-g++ should work in Arduino. For more details, see the page on the Arduino build process.

[링크 : https://www.arduino.cc/en/Main/FAQ]



아두이노 켜면 뜨는 sketch 파일은 바로 빌드 되는게 아니라 여러 단계를 거쳐서 빌드 됨

일단 소스를 보면.. 기본골격이 setup() / loop() 인데

아마도... 이런 구조로 변환하려나?


#include "board.h"

#include "wiring.h"

#define F_CPU 16000000


extern void setup();

extern void loop();

int main()

{

setup();

while(1)

{

// main loop

loop();

// event handler - not interrupt

serial_event();

}

} 

[링크 : https://www.arduino.cc/en/Hacking/BuildProcess]

[링크 : https://www.arduino.cc/en/Hacking/Preferences]



+

2016.03.28


빌드 메시지

/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/eightanaloginputs /tmp/build3729038704914021233.tmp/SerialEvent.cpp -o /tmp/build3729038704914021233.tmp/SerialEvent.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/WInterrupts.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/wiring_pulse.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/wiring_digital.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/wiring_analog.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/malloc.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/realloc.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/wiring.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/wiring_shift.c.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/CDC.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/Stream.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/main.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/WMath.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/HID.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/WString.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/HardwareSerial.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/IPAddress.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/USBCore.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/new.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/Tone.cpp.o

  Using previously compiled: /tmp/build3729038704914021233.tmp/Print.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/WInterrupts.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/wiring_pulse.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/wiring_digital.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/wiring_analog.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/malloc.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/realloc.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/wiring.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/wiring_shift.c.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/CDC.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/Stream.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/main.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/WMath.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/HID.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/WString.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/HardwareSerial.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/IPAddress.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/USBCore.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/new.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/Tone.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build3729038704914021233.tmp/core.a /tmp/build3729038704914021233.tmp/Print.cpp.o

/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build3729038704914021233.tmp/SerialEvent.cpp.elf /tmp/build3729038704914021233.tmp/SerialEvent.cpp.o /tmp/build3729038704914021233.tmp/core.a -L/tmp/build3729038704914021233.tmp -lm

/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build3729038704914021233.tmp/SerialEvent.cpp.elf /tmp/build3729038704914021233.tmp/SerialEvent.cpp.eep

/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build3729038704914021233.tmp/SerialEvent.cpp.elf /tmp/build3729038704914021233.tmp/SerialEvent.cpp.hex

바이너리 스케치 사이즈: 3,566 바이트 (최대 30,720 바이트) 


$ cat main.cpp.d

/tmp/build3729038704914021233.tmp/main.cpp.o: \

 /usr/share/arduino/hardware/arduino/cores/arduino/main.cpp \

 /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \

 /usr/share/arduino/hardware/arduino/cores/arduino/new.h \

 /usr/share/arduino/hardware/arduino/variants/eightanaloginputs/pins_arduino.h \

 /usr/share/arduino/hardware/arduino/variants/eightanaloginputs/../standard/pins_arduino.h 


$ cat /usr/share/arduino/hardware/arduino/cores/arduino/main.cpp

#include <Arduino.h>


int main(void)

{

        init();


#if defined(USBCON)

        USBDevice.attach();

#endif


        setup();


        for (;;) {

                loop();

                if (serialEventRun) serialEventRun();

        }


        return 0;

} 


'embeded > arduino(genuino)' 카테고리의 다른 글

arduino i2c 예제  (0) 2016.03.30
아두이노 on ubuntu 15.10  (0) 2016.03.28
아두이노 나노 - LED 블링크 예제  (0) 2016.03.27
아두이노 나노 - 시리얼 테스트  (3) 2016.03.27
아두이노 나노 v3.0 / v3.1  (0) 2016.03.27
Posted by 구차니
embeded/arduino(genuino)2016. 3. 27. 20:32

기본이 주기 1000 ms로 예제를 주니

100ms로 바꾸려면

const long interval = 1000;

을 

const long interval = 100;

으로 바꾸어 주면되는데...


나노의 겨우 13번 포트가 LED 연결되어 있으니 예제로 쓰긴 좋은데

USB을 뺐다가 꽂으면 왜 불규칙하게 깜박이게 될까?...


+

아두이노 IDE를 끄니 정상작동..

이녀석이 먼가 계속 핸들링 하면서 인터럽트 걸어서 그런가?

+



Posted by 구차니
embeded/arduino(genuino)2016. 3. 27. 20:19

기본 셋팅은 나의 경우에는 아래와 같이

Arduino nano 선택시 cpu는 ATmega328로 자동 선택되었고

포트는 수동으로

프로그래머도 수동으로 선택해주어야 한다.


프로그래머는 avrdude 나 stk500 등을 내장해서 굽는데

USB를 통해서 구울때는 Arduino as ISP로 설정해야 구워지네...

+

2016.04.06

어? 프로그래머 멀로 하던 알아서 굽는 느낌?

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2009 Joerg Wunsch


         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"


         Using Port                    : COM6

         Using Programmer              : arduino

         Overriding Baud Rate          : 57600

         AVR Part                      : ATmega328P

         Chip Erase delay              : 9000 us

         PAGEL                         : PD7

         BS2                           : PC2

         RESET disposition             : dedicated

         RETRY pulse                   : SCK

         serial program mode           : yes

         parallel program mode         : yes

         Timeout                       : 200

         StabDelay                     : 100

         CmdexeDelay                   : 25

         SyncLoops                     : 32

         ByteDelay                     : 0

         PollIndex                     : 3

         PollValue                     : 0x53

         Memory Detail                 :


                                  Block Poll               Page                       Polled

           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack

           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff

           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff

           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00


         Programmer Type : Arduino

         Description     : Arduino

         Hardware Version: 2

         Firmware Version: 1.16

         Vtarget         : 0.0 V

         Varef           : 0.0 V

         Oscillator      : Off

         SCK period      : 0.1 us


avrdude: AVR device initialized and ready to accept instructions


Reading | ################################################## | 100% 0.01s


avrdude: Device signature = 0x1e950f

avrdude: reading input file "C:\Users\shin\AppData\Local\Temp\build56906a4f22bf0a8b9bdb55c318239f30.tmp/sketch_mar27a.ino.hex"

avrdude: writing flash (1796 bytes):


Writing | ################################################## | 100% 1.18s


avrdude: 1796 bytes of flash written

avrdude: verifying flash memory against C:\Users\shin\AppData\Local\Temp\build56906a4f22bf0a8b9bdb55c318239f30.tmp/sketch_mar27a.ino.hex:

avrdude: load data flash data from input file C:\Users\shin\AppData\Local\Temp\build56906a4f22bf0a8b9bdb55c318239f30.tmp/sketch_mar27a.ino.hex:

avrdude: input file C:\Users\shin\AppData\Local\Temp\build56906a4f22bf0a8b9bdb55c318239f30.tmp/sketch_mar27a.ino.hex contains 1796 bytes

avrdude: reading on-chip flash data:


Reading | ################################################## | 100% 1.05s


avrdude: verifying ...

avrdude: 1796 bytes of flash verified


avrdude done.  Thank you. 




상단메뉴 tooltip 캡쳐

시리얼 모니터는 포트로 설정된 쪽에서 열리고, 업로드 시에는 자동으로(?) 꺼지게 된다.



시리얼 포트가 USB를 통해 항상 열리는게 아니기에

시리얼 모니터를 열어야 LED가 깜박이게 된다.


HTML로 복사해서 붙여 넣으니 이쁘네 ㅋㅋ

시리얼에서 무한으로 115k로 열어 Hello World 뿌려주는 예제

\r\n 넣을걸 그랬나?

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  while(1)
  {
    Serial.print("Hello world.");
  }
}



[링크 : http://www.hardcopyworld.com/ngine/aduino/index.php/archives/963]


+

2020.03.27


old bootloader로 하면 잘 된다.

[링크 : https://www.diymaker.net/121]

Posted by 구차니
embeded/arduino(genuino)2016. 3. 27. 19:50


나노 3.0 부터는 Atmega328 이라네..

ATmega328 (Arduino Nano 3.x) or ATmega168 (Arduino Nano 2.x)

[링크 : https://www.arduino.cc/en/Main/ArduinoBoardNano]


심심하니.. 아두이노 IDE나 설치


드라이버 설치 한다고 하니.. 두개가 뜨네



장치 관리자 상으로는

범용 직렬 버스 컨트롤러 - USB Serial Converter

포트(COM & LPT) - USB Serial Port(COMx)

두개만 추가 된다.


FTDI 칩을 쓰니.. 저가형 ISP로 나온 시리얼 포트를 통한 업데이트를 쓰는걸려나?


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


아두이노 스케치(?) 실행!



좌 나노 3.0

우 나노 3.1


거상인 보드(GS-08A) 와의 비교

전면은 USB 커넥터 하나고

후면은 FTDI 칩(USB) / 레귤레이터 차이 일려나?



Posted by 구차니
embeded/arduino(genuino)2016. 3. 26. 22:45

헐.. 뜯지도 않은거네 ㄷㄷ

2016/03/24 - [개소리 왈왈/직딩의 비애] - po지름wer!!!


아무튼.. 아두이노도 한번 해봐야지

usb만 꽂으면 되는거라고 하니.. 좀더 편할테니..


HS-311 표준 서보


아두이노 nano



'embeded > arduino(genuino)' 카테고리의 다른 글

아두이노 나노 - 시리얼 테스트  (3) 2016.03.27
아두이노 나노 v3.0 / v3.1  (0) 2016.03.27
아두이노 버전별 차이점  (0) 2015.10.05
아두이노 부품들...  (0) 2015.06.29
아두이노 (arduino)  (0) 2011.12.29
Posted by 구차니
embeded/arduino(genuino)2015. 10. 5. 16:52

아두이노 보면 여러가지 버전(?)이라고 해야하나?

보드가 여러가지가 존재하는데


[링크 : https://www.arduino.cc/en/Reference/SPI]


세부적인걸 제외하면

Due만 AT91SAM ARM Cortex-m3 계열이고

나머지는 AVR 계열이다.

[링크 : http://arduinomidi.com/xe/BlogBoard/9489]

'embeded > arduino(genuino)' 카테고리의 다른 글

아두이노 나노 - 시리얼 테스트  (3) 2016.03.27
아두이노 나노 v3.0 / v3.1  (0) 2016.03.27
지름 도착 - 아두이노 나노/표준서보  (0) 2016.03.26
아두이노 부품들...  (0) 2015.06.29
아두이노 (arduino)  (0) 2011.12.29
Posted by 구차니