Show Posts
Pages: 1 [2] 3 4 ... 8
16  Using Arduino / Microcontrollers / Re: Comparing crunching power or serial troughput of Uno and Micro boards on: June 13, 2013, 03:57:21 pm
I wonder how usb serial port speed compares to the teensy implementation, which is completely different.
Would a teensy owner care to run the test sketch below on a teensy?

Or can I run a sketch comiled for teensy2.0 on my leonardo? Since this sketch needs only the usb controller, no other pins ... I thought this should work and uploaded the hex file as is to my Leo. The sketch seems not to run, well the device is not enumerated...

Here is the sketch. On a Leo it prints results like this:

Leonardo, chunk size 16, sent 4096 bytes in 84 millis (46)KBpsec
Leonardo, chunk size 64, sent 4096 bytes in 74 millis (53)KBpsec


Quote
#define DATA_SIZE  4096

void setup() {
 //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

void loop() {
 
  Serial.println("*** HEADER ***");
  Serial.flush();
 
  test(16);
  test(64);
 
  while(true)
     ; 
}

#ifdef __AVR_ATmega32U4__
#ifdef CORE_TEENSY
  static const char model[] = "Teensy 2.0";
#else
  static const char model[] = "Leonardo";
#endif
#else
  static const char model[] = "not an atmega32u4";
#endif

 
void test(unsigned int chunk_size) {
 
  unsigned long t0, t1;
  unsigned int i;
 
  t0 = millis();
  for (i=0; i<(DATA_SIZE/chunk_size); i++) {
    unsigned char j;
    for (j='!'; j < '!' + chunk_size - 1; j++)
      Serial.write(j);
    Serial.write('\n');
    Serial.flush();
  }
  t1 = millis();
 
  Serial.print(model);
  Serial.print(", chunk size ");
  Serial.print(chunk_size);
  Serial.print(", sent ");
  Serial.print(DATA_SIZE);
  Serial.print(" bytes in ");
  Serial.print(t1-t0);
  Serial.print(" millis (");
  Serial.print(  ((DATA_SIZE / (t1 - t0))  * 1000u) / 1024u );
  Serial.print(")KBpsec");
}

17  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: June 11, 2013, 03:59:16 pm
Allow me to come up with a solution for what was once the subject of this thread: "Due as ISP Programmer for Leonardo/AtMega32u4": http://petervanhoyweghen.wordpress.com/2013/06/11/arduinoisp-on-the-due
18  Using Arduino / Microcontrollers / Re: ArduinoISP on Arduino DUE on: June 11, 2013, 03:48:12 pm
It works pretty stable now. I have an ArduinoISP sketch that runs out of the box on the Due. There is a mini howto here: http://petervanhoyweghen.wordpress.com/2013/06/11/arduinoisp-on-the-due
19  Using Arduino / Microcontrollers / Re: Comparing crunching power or serial troughput of Uno and Micro boards on: June 10, 2013, 04:09:16 pm
I did some measurements with a (borrowed) usb analyzer. I took the ASCIITable example, changed the baudrate to 115200, compiled it with ide 1.0.5 and uploaded it to a Duemilanove and a Leonardo. (It is a pity I don't have an Uno). 

The dataflow looks like this:

The Duemilanove sends 4974 bytes in 368 msec (13.52KBps). About every msec ~14 bytes get sent.
(The duemilanove has to send more data because the ftdi protocol sends two bytes protocol header upon every chunk of data. So the 14 bytes are only 12 bytes useful payload)

The Leonardo sends 4224 bytes in 151 msec (27.14KBps). About every msec ~30 bytes get sent.

So the native USB is indeed faster, but not spectacularly and nohere near the theoretical upperbound of 12Mbps. 

But actually I expected even worse, I noticed the code in CDC.cpp sends out one byte at a time, but fortunately the lower level puts the single bytes into the hw fifo. When the fifo is full, it gets send out as one chunk over USB.

The chunks are 64 bytes (max packet size) (not 256). No idea why I see only 30 bytes. Will do a test sending out 1 byte in loop to avoid effects/delays imposed by formatting code...

More importantly the fifo is flushed only once per frame of1 msec. The analyzer shows that the host is polling ~75 times more for new data during the rest of the frame...  I think this is the first place to look for improvements
20  Using Arduino / Microcontrollers / Re: Comparing crunching power or serial troughput of Uno and Micro boards on: June 07, 2013, 02:50:06 pm
On the other hand, using the micro's native USB there is no real uart in the game that is normally the bottleneck.

I think the core's implementation for sending from the arduino is simple but not optimized. WIth a little tweaking I expect this can be made much faster than the classic uart.

Can you tell us how at what pace data becomes available, and how many bytes it are? Then with a simple sketch we could measure performance difference real uart versus virtual com port over native usb.

21  Using Arduino / Microcontrollers / Re: Auto-reset not working on modified Leonardo bootloader on: June 05, 2013, 03:42:08 pm
Once the sketch runs, the usb code from the core is in action, not that from the bootloader.
Does the board show up correctly in device manager once the sketch runs?

The autoreset code is in CDC.cpp. You might want to instrument it to see whether linestate changes whilst baud rate is 1200bps.

Auto reset uses the watchdog timer. I think this needs the WDTON fuse bit. Compare high fuse byte against what is in boards.txt: 0xd8.
22  Products / Arduino Due / Re: SPI.end() causes SPI.transfer() to hang even after a new SPI.begin() on: June 04, 2013, 05:11:57 pm
Almost, the initcb() (which is SPI_0_Init()) has to be called too.
Thanks!
23  Products / Arduino Due / Re: SPI.end() causes SPI.transfer() to hang even after a new SPI.begin() on: June 04, 2013, 03:00:20 pm
I am using the old AVR compatible api's.
I can confirm the above work around works for me too.

But after calling SPI.end(), I want to tristate SCK and MOSI. How do I do that? I tried adding
Code:
pinMode(MOSI, INPUT);
pinMode(SCK, INPUT);
But after that SPI.begin() does not work anymore.
I dare not configuring them as output before calling SPI.begin() because I noticed that SPIClass::begin() does not have code in it to do so, that is probably done for a reason.
24  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: June 04, 2013, 02:40:08 pm
@coolf: I normally use linux, but for verification I tried the command line myself on windows 7 SP1 64bit.
As  explained we can use the avrdude (and later the leo bootloader) from the 1.0.3 ide:
Code:
arduino-1.0.3\hardware\tools\avr\bin>avrdude.exe -C ..\etc\avrdude.conf -c arduino -P COM10 -p m32u4  -U signature:r:test.hex:h

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude.exe: Device signature = 0x1e9587
avrdude.exe: reading signature memory:

Reading | ################################################## | 100% 0.04s

avrdude.exe: writing output file "test.hex"

avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.
25  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: June 04, 2013, 02:13:24 pm
@reinaldoaff: just specify 255 instead.
(actually I noticed it gets overwritten anyway by SPI::begin(), so we'll be spi!ing at 4MHz anyway, but this is ok, it works)
26  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: June 04, 2013, 11:08:24 am
Don't give up.
I have the same Due and the same Leo, if it works for me it must work for you too.

Try to work incrementally. First make isp work from the command line.
Go to the arduino-1.5.2/hardware/tool directory and enter this command:
Code:
avrdude.exe -C avrdude.conf -c arduino -P YOURDUECOMPORT  -p m32u4 -vvvv -U signature:r:test.hex:h

I assume you use the native usb port.

Post the output here.
27  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: May 30, 2013, 11:21:31 am
Quote
I would love to say: IT`s working Jipppii, but i can`t.
Don't worry we'll get there.

Let us first get the power aspect right. I want to avoid someone damages his or her Due because of reading this thread.

Quote
I changed the connection pin. power supply of the target (Vin = 3.3V) to the Vdd(5V) pin
Not sure how to interpret this, but I meant following:

Code:
Pin Due    |    Pin Leonardo
3.3V       |    5V

This is what I used. I found it an intuitive way to power the atmega32u4 at 3V3. From the schematcs of the Leonardo, I don't see a problem with this, but of coarse I might overlook something. (Any feedback about this is wellcome). Anyway I experienced no neagtive effect of it.

Very important: never plug in the Leo's usb port while this wiring is in place (Leo powered by the Due's 3V3) !

Now, about the call stack trace: I remember some issues being reported with the way 1.5.2 deals with sketchbook directories.

So there are two approaches:
1. Leave the "leofix" in place and burn the bootloader using ide 1.0.3 or higher. The ide does not care your programmer happens to run on a Due.
2. Remove the "leofix" (remove again the hardware directory from your sketchbook directory). Instead, directly modify arduino-1.5.2/hardware/arduino/avr/programmers.txt: change these items:
Code:
arduinoisp.protocol=stk500v1
arduinoisp.program.protocol=stk500v1
into
Code:
arduinoisp.protocol=arduino
arduinoisp.program.protocol=arduino
Also make sure the baud rate is correct (19200).
The arduinoisp.program.xxx entries are new to me, but the only goal is to use arduino as protocol because you are on windows.

28  Using Arduino / Microcontrollers / Re: Due as ISP Programmer for Leonardo/AtMega32u4 on: May 29, 2013, 02:36:30 pm
I connected the 3V3 of the Due (don't take the adjacent 5V by mistake)  to Vdd ("5V") of the Leonardo
About the programmer: on windows you should do the "Leofix trick" see:http://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/, step 7.
Also do this SPI fix: http://forum.arduino.cc/index.php?topic=165497.0

It is better to first try something simpler: download the booter from the device or read out the signature bytes, so you know isp works.


29  Products / Arduino Due / Re: Updating 16u2 USB firmware on: May 25, 2013, 03:41:46 pm
You could download the current firmware from the 16u2 and compare it to what is in the ide.
Use ArduinoISP on the UNO as programmer. The avrdude command would look like this:

Code:
arduino-1.5.2/hardware/tool> avrdude.exe -C avrdude.conf -c arduino -P COMyour_com_port -b 19200 -p m16u2 -vvv -U flash:r:old.hex:i

http://arduino.cc/en/Hacking/Upgrading16U2Due
http://petervanhoyweghen.wordpress.com/2013/02/25/modifying-the-atmega16u2-firmware-on-the-due/
30  Using Arduino / Microcontrollers / Re: ArduinoISP on Arduino DUE on: May 23, 2013, 03:42:54 pm
Quote
Have you considered working with TinyISP instead of ArduinoISP?
I did not know about it. I heard about it but associated the name TinyISP to the attiny based programmer by adafruit. Seems to contain a lot of interesting ideas, I will certainly give it a try. Though it would not work for the Due because of the AVR SPI registers and the AVR assembler...

Thanks Coding Badly for the feedback about the attiny max ISP speed, thanks everybody for the new insights.

Using bitbang SPI, I could now successfully program an attiny85 from the Due (native port only, programming port still gives problems even with autoreset disabled...). Will polish this a bit up and write about it...
Pages: 1 [2] 3 4 ... 8