Now it is the first time I am using an arduino board. Arduino mega 2560 is really a great product. The chip got a flash of 256KB, RAM of 8KB and EEPROM of 4KB. Also, the data sheet of Atmega2560 says that we can extend the RAM (by external) upto 64KB. Another most important feature of this stuff is that it have 54 Digital I/O pins (of which 14 provide PWM output). It is clocked with a 16MHz crystal osc.
Also the board contains another atmega16 (just above the crystal) which is pre-programmed as a USB to UART converter which enables a serial communitation between the atmega2560 and PC via USB. The product is shipped with a bootloader inside which make it easy to program it via the same USB-UART channel. So the channel got two functions, ie programming the chip and serial communication with PC. From the arduino home page we can download the arduino IDE for appropriate OS.
- extract it. (tar -xvf pymite-xx.tar.gz)
- ‘cd’ into the directory of pymite folder
- now, cd into src/platform/arduino_mega and open the Makefile
- edit the platform configuration MCU to atmega2560
- now cd back to the pymite folder (cd ../../../)
- now type “make PLATFORM=arduino_mega”
- now if you see any error as below:
avr-gcc -c -mmcu=atmega2560 -I. -gstabs -DF_CPU=16000000UL -I../../vm -I/home/vinod/pymite-09/src/platform/arduino_mega -Os -Wall -Wstrict-prototypes -Werror -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums main_nat.c -o main_nat.o In file included from main_nat.c:20:0: /usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h: In function 'nat_05_avr_delay': /usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:153:28: error: __builtin_avr_delay_cycles expects an integer constant. /usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:153:28: error: __builtin_avr_delay_cycles expects an integer constant. make[1]: *** [main_nat.o] Error 1 make[1]: Leaving directory `/home/vinod/pymite-09/src/platform/arduino_mega' make: *** [all] Error 2
- if the above error occur, then open the file src/platform/arduino_mega/
- Now add below function under the #include <util/delay.h>
//------------------- void delay_MS(unsigned int n){ unsigned int x; while(n--){ x=2600; while(x--); } }
-
- Now edit the function nat_05_avr_delay(pPmFrame_t *ppframe) in the opened file. Replace the _delay_ms( with delay_MS( and save it.
- Now go back to pymite (cd ../../../) and type “make PLATFORM=arduino_mega” or type simply “make” from the current folder and if no errors, we could see a main.elf file generated in the arduino_mega folder.
- Now convert it to hex using below command.
- avr-objcopy -j .text -j .data -O ihex main.elf python.hex
- Now we obtained the hex file and we need to burn it to arduino mega 2560, for that we can use avrdude command as below.
- sudo avrdude -V -F -c stk500v2 -p m2560 -b 115200 -P /dev/ttyACM0 -U flash:w:python.hex
- Now the hex is loaded into arduino and we can test it. For that, cd into the directory of the arduino_mega (cd src/platform/arduino_mega) and type ../../tools/ipm.py -f pmfeatures.py –serial /dev/ttyACM0 –baud=57600
Now if every thing is okay, then we could see an ipm prompt and we can test simple python codes. Below is some of my test codes and screen shots.
- I got one more product from element14, an arduino ethernet shield. I tried the basic examples of google search, twitter etc on it and it is working fine. Also there is a micro sd card slot which is very much helpful to easily interface a micro sd card to the arduino.. It is a cool stuff….