General Arduino/Atmel question

I am new to Arduino, however I have used Atmel microcontrollers for projects where I work.

I have so many questions, but I will try to ask only one here…

Is the Atmel processor on an Arduino board ever programmed “directly”, with a compiled c program, without using the Arduino interrupter/os resident on the Arduino board?

The fact that I am typing this question in the “AVR Programmers” forum, makes me think that the answer to this question is “yes”…

The thing that led me to asking this is that I want to implement interrupt driven SPI slave on an Arduino board, and I can’t find that functionality in the Arduino programming reference. Actually, I can’t find any information about using interrupts in the programming reference.

That might have been more than one question… I would appreciate any info in regard to this…

The AVR can be programmed and debugged in the usual way if the board has the appropriate connector.

Leon

You can also use the Arduino boot loader to load your normal, non-Arduino-framework applications .

Thanks for the replies… After spending some time looking at the Sparkfun site, I am starting to think that the Olimex boards are what I need rather than Arduino…

I assume I can compile a c program with avr-gcc compiler then program the avr processor on the Olimex board with an in-system programmer…

At least, that is what i am thinking at this moment in time…

If you get an Atmel Dragon you can debug the application as well.

Leon

leon_heller:
If you get an Atmel Dragon you can debug the application as well.

Leon

or

http://www.nkcelectronics.com/pocket-av … ammer.html

or an AVRstudio compatible cheapie

http://www.nkcelectronics.com/avr-jtag- … r-kit.html

Olimex are good but just one of many.

Most are listed on avrfreaks.net website and user forum

Using the arudino dev platform gives a quick and inexpensive way to program avr based MCU’s, even if you’re not using the ‘arduino’ IDE to code. You can still program in assembly, or using avr-gcc, or whatever you wish. The arduino bootloader gives you a quick way of loading your program to the MCU via a serial interface. This allows you to program via serial, and use hardware/software UARTS for debugging or development, whereas if you wanted that without the arduino bootloader you’d need both your ISP programmer as well as a serial adapter. Lately I’ve simply been using the ATMega chip with arduino bootloader (along with supporting components), and Eclipse with the AVR plugin. This allows me to develop code/libraries that will work with both my ATMega chips as well as my ATTiny chips (no bootloader on those tho). So far the only real disadvantage I’ve found from this approach is that the bootloader takes up 2k of program memory.

I would however still recommend having a ISP/HV programmer to allow you to set/reset fuse bits, and would more lean towards a HV programmer just in case you mess up the fusebits and are not sure what exactly you set them to. For example, a HV programmer will allow you to set fuse bits without a crystal even if fuse bits indicate it needs one.

Thanks, this is starting to become clear to me…i think…

So, should I be able to use Minicom, connected to /dev/ttyUSB0, to send the *.hex file to the Arduino board?

Or is there some sort of initialization that needs to be sent before the hex file?

Also, if the Arduino board can be programed this way, what is the correct baud rate?

You’ll need to use “avrdude”. AFAIK the bootloader emulates some sort of ISP, probably the mkII. You can then configure avrdude to program the device with a USB.

you might be able to bitbang the serial port, but you can use lehmanna’s suggestion and use avrdude as well (probably easier and more reliable). I think the bootloader emulates the stk500v1 programmer, search around for programming the arduino with avrdude and you should be able to find some examples.

If you have or can get access to an AVR ISP, here’s a free AVR bootloader (512 bytes) with matching PC side program that has a graphical user interface…

http://www.avrfreaks.net/index.php?modu … tem_id=625

krphop:
you might be able to bitbang the serial port, but you can use lehmanna’s suggestion and use avrdude as well (probably easier and more reliable). I think the bootloader emulates the stk500v1 programmer, search around for programming the arduino with avrdude and you should be able to find some examples.

Yes, exactly, I was mistaken. It’s the stk500.

I seem to be getting close I am using this command…

avrdude -v -F -p atmega168 -P /dev/ttyUSB0 -c stk500 -b 19200 -U flash:w:sketch_090913a.hex

I can see the Rx led blink on the Arduino board.

However arvdude says…

avrdude: ser_recv(): programmer is not responding

avrdude: stk500_recv(): programmer is not responding

Also this is an ATMEGA328 Arduino board, but there does not seem to be a -p code for that processor, so i am using -p atmega168…

I just realized that when i am running “arvdude” from the command line, it is running “/usr/bin/avrdude” which is not the arvdude that Arduino is using.

That is why it did not recognize the atmega328 processor.

So I set the verbose values in preferences.txt to true, and did an “upload to i/o board” so that I could see the exact command line that Arduino is using, which happens to be…

/root/arduino/arduino-0016/hardware/tools/avrdude -C/root/arduino/arduino-0016/hardware/tools/avrdude.conf -v -v -v -v -pm328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/root/sketchbook/sketch_090913a/applet/sketch_090913a.hex:i

So I entered that on the command line, and I still get…

avrdude: ser_recv(): programmer is not responding

avrdude: stk500_recv(): programmer is not responding

I REALLY thought it was going to work this time…

How can the exact command that Arduino uses, get no response from the programmer when entered from the command line…??

Are you sure your device is showing up as /dev/ttyUSB0?

Yes it is /dev/ttyUSB0.

In fact I do see the Rx led on the Arduino board blink when I enter the command…

It all worked! What a great day…

I compiled a c source file with avr-gcc.

Then converted the object file to ascii hex file with avr-objcopy.

Then, I FINALLY got avrdude to connect with the ISP on the Arduino.

I pressed the reset button on the Arduino board right before i entered the arvdude command and it worked.

Then after I did that the first time, I didn’t need to press the reset button again to get it to work. (for whatever reason??)…

Thanks everyone for helping me through this today…I’m going to bed…