Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
Today I have got my new Arduino Duemilanove (2009) board (http://arduino.cc/en/Main/ArduinoBoardDuemilanove), and started running the example programs. Everything is so easy and simple! I was little bit curious about their Programming architecture in C/C++. It doesn't use the traditional main() function. Instead of it, Arduino uses two functions: setup() and loop(). How is this working?Are they using any interpreter to interpret Arduino-standard code to traditional C (AVR GCC)?
Before using Arduino, I was using my own designed ATmega8/ATmega168 Board (http://robotalk.codecake.com/2008/09/14/atmega8-development-board/) and AVR Studio 4 with AVRISP mkII. The reason I have jumped (not really jumped; just for curiosity) to Arduino is it's easy-to-use software library.Is it possible to run Arduino Code on my own custom board (specified the link above)?
Will it work if I just burn the HEX file to the ATmega168 on my custom board? Does the hardware need to be changed then?
I was writing code using traditional AVR GCC (not C++), which is a big hassle comparing with the easy programming technique of Arduino. That is why I need to switch to their Library, and off course, without using their Hardware.Is it also possible to mix up both programming style: the regular AVR GCC and Arduino C/C++?
As far I know, AVR GCC only supports C-style code, not C++. Please, correct me if I am wrong.Finally one more question:Is it possible to write an Arduino Library using AVR GCC? Or, do I have to use their style of Coding to build a new library?
Binary sketch size: 1124 bytes (of a 14336 byte maximum)avrdude: verification error, first mismatch at byte 0x0002 0x5a != 0x34avrdude: verification error; content mismatch
################################################################################ Makefile for the project mega168_boot################################################################################# General FlagsPROJECT = mega168_bootMCU = atmega168TARGET = mega168_boot.elfCC = avr-gcc.exe## Options common to compile, link and assembly rulesCOMMON = -mmcu=$(MCU)## Compile options common for all C compilation units.CFLAGS = $(COMMON)CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DMAX_TIME_COUNT=F_CPU>>4 -DNUM_LED_FLASHES=1 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsCFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d ## Assembly specific flagsASMFLAGS = $(COMMON)ASMFLAGS += $(CFLAGS)ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2## Linker flagsLDFLAGS = $(COMMON)LDFLAGS += -Wl,-Map=mega168_boot.map## Intel Hex file production flagsHEX_FLASH_FLAGS = -R .eepromHEX_EEPROM_FLAGS = -j .eepromHEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings## Objects that must be built in order to linkOBJECTS = mega168_boot.o ## Objects explicitly added by the userLINKONLYOBJECTS = ## Buildall: $(TARGET) mega168_boot.hex mega168_boot.eep mega168_boot.lss size## Compilemega168_boot.o: ../mega168_boot.c $(CC) $(INCLUDES) $(CFLAGS) -c $<##Link$(TARGET): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)%.hex: $(TARGET) avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@%.eep: $(TARGET) -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0%.lss: $(TARGET) avr-objdump -h -S $< > $@size: ${TARGET} @echo @avr-size -C --mcu=${MCU} ${TARGET}## Clean target.PHONY: cleanclean: -rm -rf $(OBJECTS) mega168_boot.elf dep/* mega168_boot.hex mega168_boot.eep mega168_boot.lss mega168_boot.map## Other dependencies-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)