Show Posts
Pages: 1 2 [3] 4 5 ... 8
31  Using Arduino / Microcontrollers / Re: Programming Arduino 328 MINI with Leonardo on: April 12, 2013, 01:19:40 pm
Do you use the leo or did you buy an usb to serial converter?
If you use the leo, could you post a picture of your setup?
32  Using Arduino / Microcontrollers / Re: Programming Arduino 328 MINI with Leonardo on: April 11, 2013, 03:57:04 pm
EDIT : It looks like the Nick Gammon's programmer is only burning bootloader, isn't it ?
Yes, and that should work (or can be made to work) from the leonardo, but it is probably not needed since the mini comes with a bootloader preburned. So I would start checking the bootloader is still present and working by connecting a led and resistor to the mini's pin 13 and see whether it blinks at least briefly upon startup.

If it does, you can indeed use the leo as usb to serial converter. I see you already found my writeup

You can simplify things a bit.
Using both of following simplifications you don't need to do the hacks described after the sketch  in the write up:
1. Use the sketch for the leo from the link above, but change the baudrate line like this:
static long baud = 115200;
. This way the leo uses the same baud rate as the mini's boot loader from the beginning.
2. reset the mini manually (don't connect the mini's reset pin to the leo). Do you have the mini version with the reset button? If not wire one up.

33  Using Arduino / Microcontrollers / Re: Arduino Miro running ArduinoISP on: March 31, 2013, 04:57:54 pm
Are you running on windows? If yes, using -c arduino instead of -c avrisp should get you further.
See, most of that stuff is applicable to the Micro too.
34  Using Arduino / Microcontrollers / Re: ArduinoISP on Arduino DUE on: March 28, 2013, 04:16:59 pm
So I should replace every instance of Serial with SerialUSB and then use the programming port to upload the sketch ArduinoISP, after that connect the DUE board to the native port and flash the sketch on the external uC?
Do you think I can use the onboard SPI 6 pins?
Yes that is the one to use but be carefull that the target uc does not drive the SPI pins at 5V or the due is damaged. As said before I powered the target at 3V3 to ensure this. (In particular, I left the VCC pin on the Due's SPI headers un connected: it is 5V!)

As said I can't program nor run my attiny at 3V3, allthough according to the datasheet it should work (BOD is disabled). Maybe my attiny is broken, maybe I am missing something.  (If somebody has ideas, that would be great).

35  Using Arduino / Microcontrollers / Re: ArduinoISP on Arduino DUE on: March 27, 2013, 03:53:48 pm
It can be done, but if you have an alternative (uno, leo...) that is more practical.

First of all, the due is not 5V tolerant. I solved this the simplest way by powering the target AVR with 3V3. This worked for me for ISP'ing my Leonardo and a Duemilanove. It failed for an attiny85...

The sample ArduinoISP in the ide is rather old, it should be updated. So get ArduinoISP here: That version is updated to use the SPI library instead of implementing the spi stuff inside the sketch using the AVR specific registers.

I used an SPI clock divider of 255 (the slowest one), the constant in the ArduinoISP sketch is not defined for the Due.

Then there is the autoreset problem. The due's native port autoresets when you open it, this is a classical problem that will cause "burning a bootloader via the ide" to fail. A good alternative is to replace all occurences of Serial into SerialUSB and thus use the native usb port instead of the programming port. This port does not autoreset when opening it.

Finally, I observed a problem when stopping and restarting SPI. But as said, I managed to upload a bootloader into a Leonardo and a Duemilanove.

I am preparing writeups on how to disable autoreset for the programming port and on running ArduinoISP on the due but I am a bit behind with things...
36  Using Arduino / Microcontrollers / Re: Problem with custom Atmega2560 board, cannot use FT232 for Serial comms on: March 19, 2013, 05:49:22 pm
The chip/driver must auto-detect the baud rate coming from the processor, and they seem not to be doing as good a job as the 8U2 chip.
How do you mean? Neither the ftdi nor the 8u2's firmware do that, they just impose the baudrate sent over usb by the pc on their uart.

About the theory of overflowing the ftdi's 64 byte buffer. What if you send data only every say 30 msec? (the buffer is flushed over usb after a configurable timeout which is 16msec by default).

How is the ftdi connected? Is there an auto reset line (DTR or RTS) towards the atmega? Are the other flow ctrl signals connected (toggling cts,... flushes the buffer too)
37  Products / Arduino Due / Re: Arduino as ISP for ATtiny Hardware not recognized on: March 03, 2013, 11:08:14 am
Are you really trying to use the Due as ArduinoISP?

If not, use the ide 1.0.3 instead, it works.

If yes, it can be done but it does not work out of the box, and it is not very practical because the Due's SPI signals are 3V3... I managed to isp a leonardo and a duemilanove using the due as programmer. I powered theses targets with 3V3 to do this. I tried the same with an attiny but that did not work for some reason...
Also you need to get the latest ArduinoISP from rsbohn's github, because that one uses the SPI library instead of thge AVR's SPI register interface.
(I plan a write up about this...)

To use the tiny core, first load ArduinoISP in the due using ide 1.5.2 and then do the tiny stuff using ide 1.0.3.
38  Using Arduino / Microcontrollers / Re: Trying to flash ATMega16U2 of Arduino UNO R3, using Atmel AVRISP MKII on: March 03, 2013, 08:19:57 am
It could be that the atmega16u2 is ok, but the uno has no bootloader anymore:
After that, you can Shift+Upload (Upload using programmer) in the Arduino IDE.
This erases the bootloader. Could it be that uploading stopped working after you tried this for the first time?
If so, try to burn a bootloader to the uno using the avrisp mkII.
39  Products / Arduino Due / Re: arduino due serial is not working on: February 25, 2013, 03:44:47 pm
It is not the serial port that would force the upgrade, it is the composite device.

Downloading a "serial port only" sketch, will work for mac 10.6.8 too.
I just tried the approach I posted before, and can confirm it works on the Due.
(tested on linux, due native port enumerates as serial port only and ASCIITable sample works (when using SerialUSB instead of Serial, I missed that on your first post))
40  Products / Arduino Due / Re: arduino due serial is not working on: February 23, 2013, 06:05:08 pm
It was reported that this does only work since mac os lion.
See here:,137032.msg1031089.html#msg1031089

Previous versions of mac os lack support needed for composite devices (the native port exposes a  composite device: serial + hid). If you only need a serial port you might create and upload a sketch that is a serial port only. I had that running on the leonardo. It probably can be made working on the due too. See here:,137032.msg1033088.html#msg1033088
41  Products / Arduino Due / Re: Updating 16u2 USB firmware on: February 12, 2013, 04:44:20 pm
I used ArduinoISP on my leonardo. If your not familiar with this stuff, practice a bit with another (cheaper) board.
Then try downloading the current firmware from the due's atmega16u2, for future reference and to check whether your setup is reliable.

On the Due, pick the ISP header next to the atmega16u2!!! (One time I almost picked the other one, just by habbit, which is not 5V tolerant)

I used this cmd line on linux:
/opt/arduino-1.5.2/hardware/tools/avrdude -C /opt/arduino-1.5.2/hardware/tools/avrdude.conf -p m16u2 -b 9600 -c avrisp -P /dev/ttyACM1  -U flash:r:due-fw-ori.hex:i

I had to use avrdude from arduino, because the one on my system had no support for the m16u2.

On windows it goes like this (note the -C arduino is needed when using leonardo as isp):
C:\Users\peter\arduino-1.5.2/hardware/tools/avr/bin/avrdude -C C:\Users\peter\arduino-1.5.2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -p m16u2 -c arduino -P COM6 -b 9600 -Uflash:r:due-fw-ori.hex:i

Then burn the new firmware:
On linux:
/opt/arduino-1.5.2/hardware/tools/avrdude -C /opt/arduino-1.5.2/hardware/tools/avrdude.conf -pm16u2 -b 9600 -c avrisp -P /dev/ttyACM1  -U flash:w:Arduino-DUE-usbserial-prod-firmware-2013-02-05.hex:i
On windows:
C:\Users\peter\arduino-1.5.2/hardware/tools/avr/bin/avrdude -C C:\Users\peter\arduino-1.5.2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -p m16u2 -c arduino -P COM6 -b 9600 -Uflash:w:Arduino-DUE-usbserial-prod-firmware-2013-02-05.hex:i
42  Products / Arduino Due / Re: Data loss when sending to native USB port (SerialUSB) on: February 04, 2013, 04:44:28 pm
I read you have Albert's test running. Is it easy to test with SerialUSB?
43  Products / Arduino Due / Re: Data loss when sending to native USB port (SerialUSB) on: February 04, 2013, 04:39:36 pm
What happens for me is that echo blocks until ttyACM1 accepts the data.

Well, that is what I expected to happen for me too when I wrote the script. (And on another pc (linux 3.5 vs. 3.0.0)),  I did actually observe echo blocking). The point I wanted to make is that having no circular buffer, one could temporarily block a program on the pc.

But you are right. Closing and reopening the file every time causes the os to flush the file and this makes echo block. If a program would write to ttyACM1 in a normal way, the os would buffer the output... So it looks like we can indeed live without the buffer in the Due.

44  Products / Arduino Due / Re: Data loss when sending to native USB port (SerialUSB) on: February 03, 2013, 05:07:33 pm
Hi Stimmer,

I found kicking out the circular buffer a great demonstration "out of the box" thinking.

I have tested your implementation with ArduinoISP. I think this is a good real life use scenario of the serial port, with lots of messages of different sizes (though relatively small) in both directions. I powered my leonardo from the due's 3v3 and modified ArduinoISP to use SerialUSB instead of Serial. It worked well: I could upload download the bootloader to/from the leonardo several times.

Nevertheless dropping the serial buffer also has consequences for feeding the due lots of small messages. Each message is received in a separate bank and you only have two of them. Take for example this shell script:
while true; do

        echo "$n" > /dev/ttyACM1
        echo $?
        sleep 1
        let "n = $n + 1"

I ran this sketch on the due:
static const int led = 13;
static const int button = 3;

void setup() {
  // initialize serial:
  pinMode(led, OUTPUT);     
  pinMode(button, INPUT);
  digitalWrite(button, HIGH);

void loop() {
  // if there's any serial available, read it:
  int i = 0;
  if (digitalRead(button)) {
    while (SerialUSB.available() > 0) {
      char c =;
  digitalWrite(led, HIGH);
  digitalWrite(led, LOW);

If you press the button for a few seconds, some of the messages are lost.
Odd enough the return code of echo is always 0.

I am not sure where the bytes get lost. And maybe it can be prevented with stty calls, but a circular buffer would prevent this. A circular buffer which you fill up with memcpy would also make sense as an implementation.

45  Products / Arduino Due / Re: Data loss when sending to native USB port (SerialUSB) on: January 30, 2013, 04:38:59 pm
Update: PeterVH, I tried your fix without the guard but I can't get it to work reliably. It works for 100KB or so, then corruption, then nothing.

I can confirm the behavior. I had only tested with an 8KB file. With an 170K file I have corruption too: it goes well for some time but then each  byte gets sent several times.

I don't understand. I also tried with replacing the guard code with:
irqflags_t flags = cpu_irq_save();
... body of accept ...
The idea was instead of avoiding the isr to enter the routine, to avoid an isr alltogether by disabling interrupts. It does not work either.

The good thing is that I can also confirm the version in github works ok (tested with a 170KB file).

I will do tests with ArduinoISP also.

Pages: 1 2 [3] 4 5 ... 8