Arduino Due libraries (official and 3rd party)

a library for DUE / UNO / teensy which can handle multiple AD9850 modules connected to SPI

Can someone show me how to use MFRC 522 on arduino DUE? it's running on nano uno and mega. but i cant make it work on DUE. my project need to use DUE and not other arduino. so please can anyone teach me how. im new in using arduino DUE. TIA

I need to use a complex math library for a school project. I found a library of that kind in this link: https://playground.arduino.cc/Main/ComplexMath but it doesn't compile in Arduino DUE. I think that I need to change something in either complex.cpp or complex.h but I don't know what to change.

When I try to upload the complex example of this library mentioned above, the following errors appear:

complex:16: error: 'COMPLEX_LIB_VERSION' was not declared in this scope

Serial.println(COMPLEX_LIB_VERSION);

^ complex:19: error: 'Complex' was not declared in this scope

Complex c1(10.0, -2.0);

^

complex:19: error: expected ';' before 'c1'

Complex c1(10.0, -2.0);

^ complex:20: error: expected ';' before 'c2'

Complex c2(3, 0);

^ complex:21: error: expected ';' before 'c3'

Complex c3(-10, 4);

^ complex:22: error: expected ';' before 'c4'

Complex c4(-5,-5);

^ complex:23: error: expected ';' before 'c5'

Complex c5(0, 0);

^ complex:25: error: 'one' was not declared in this scope

Serial.println(one);

^ complex:26: error: 'c1' was not declared in this scope

Serial.println(c1);

^ complex:27: error: 'c2' was not declared in this scope

Serial.println(c2);

^ complex:28: error: 'c3' was not declared in this scope

Serial.println(c3);

^ complex:29: error: 'c4' was not declared in this scope

Serial.println(c4);

^ complex:36: error: 'c5' was not declared in this scope

c5 = c1;

^

exit status 1 'COMPLEX_LIB_VERSION' was not declared in this scope

Does someone have any idea how to fix it?

I would really appreciate your help by telling me what to change or maybe it would be easier if someone shares the files of a complex library that works in Arduino DUE.

Beforehand thanks a lot.

I tried to upload this Library this way, and I think it works (at least, I have no error at compile time):

Open a new sketch that you can call Complex.ino :

//
//    FILE: complex.ino
//  AUTHOR: Rob Tillaart
//    DATE: 2013-09-23
//
// PUPROSE: test complex math
//
// Serial.print(Complex) supported since 0.1.05

#include "complex.h"

void setup()
{
  Serial.begin(115200);
  Serial.print("\n  Complex numbers test for Arduino: ");
  Serial.println(COMPLEX_LIB_VERSION);
  Serial.println("\n1. Print Complex, set, real, imag");

  Complex c1(10.0, -2.0);
  Complex c2(3, 0);
  Complex c3(-10, 4);
  Complex c4(-5,-5);
  Complex c5(0, 0);

  Serial.println(one);
  Serial.println(c1);
  Serial.println(c2);
  Serial.println(c3);
  Serial.println(c4);
  c3.set(0,0);
  Serial.println(c3);
  Serial.println(c3.real());
  Serial.println(c3.imag());

  Serial.println("\n2. ==  != ");
  c5 = c1;
  if (c5 == c1) Serial.println("ok :)");
  else Serial.println(" fail :(");
  c5 = c1 + 1;
  if (c5 != c1) Serial.println("ok :)");
  else Serial.println(" fail :(");
  c5 = 3;
  if (c5 == 3) Serial.println("ok :)");
  else Serial.println(" fail :(");


  Serial.println("\n3. negation - ");
  c5 = -c1;
  Serial.println(c5);
  c5 = -c5;
  Serial.println(c5);
  if (c5 == c1) Serial.println("ok :)");
  else Serial.println(" fail :(");


  Serial.println("\n4. + - ");
  c5 = c1 + c2;
  Serial.println(c5);
  c5 = c1 + 3;
  Serial.println(c5);
  c5 = c1 - c2;
  Serial.println(c5);
  c5 = c1 - 3;
  Serial.println(c5);


  Serial.println("\n5. * / ");
  c5 = c1 * c2;
  Serial.println(c5);
  c5 = c5 * 3;
  Serial.println(c5);
  c5 = c5 / c2;
  Serial.println(c5);
  c5 = c5 / 3;
  Serial.println(c5);

  c5 = c1 / c2 * c2;
  Serial.println(c5);
  c5 = c1 * c4 / c4;
  Serial.println(c5);


  Serial.println("\n6. assign += -= *= /=");
  c5 = c1;
  c5 += c1;
  Serial.println(c5);
  c5 += 3;
  Serial.println(c5);
  c5 -= c1;
  Serial.println(c5);
  c5 -= 3;
  Serial.println(c5);
  c5 *= c1;
  Serial.println(c5);
  c5 *= 3;
  Serial.println(c5);
  c5 /= c1;
  Serial.println(c5);
  c5 /= 3;
  Serial.println(c5);


  Serial.println("\n7. phase modulus polar");
  Serial.println(c1);
  double m = c1.modulus();
  Serial.println(m);
  double p = c1.phase();
  Serial.println(p);
  c5.polar(m, p);
  Serial.println(c5);


  Serial.println("\n8. conjugate reciprocal");
  c5 = c1.conjugate();
  Serial.println(c5);
  c5 = c5.conjugate();
  Serial.println(c5);
  c5 = c1.reciprocal();
  Serial.println(c5);
  c5 = c5.reciprocal();
  Serial.println(c5);

  Serial.println("\n9. power: exp log pow sqrt sqr logn log10");
  c5 = c1.c_sqr();
  Serial.println(c5);
  c5 = c1.c_exp();
  Serial.println(c5);
  c5 = c5.c_log();
  Serial.println(c5);
  c5 = c1.c_pow(2);
  Serial.println(c5);
  c5 = c5.c_sqrt();
  Serial.println(c5);
  c5 = c5.c_sqr();
  Serial.println(c5);
  c5 = c1.c_pow(c2);
  Serial.println(c5);
  c5 = c5.c_pow(c2.reciprocal());
  Serial.println(c5);
  c5 = c5.c_logn(c4);
  Serial.println(c5);
  c5 = c4.c_pow(c5);
  Serial.println(c5);
  c5 = c5.c_log10();
  Serial.println(c5);

  Serial.println("\n10. gonio: sin cos tan asin acos atan");
  c1.set(0.5, 0.5);
  c5 = c1.c_sin();
  Serial.println(c5);
  c5 = c5.c_asin();
  Serial.println(c5);
  c5 = c1.c_cos();
  Serial.println(c5);
  c5 = c5.c_acos();
  Serial.println(c5);
  c5 = c1.c_tan();
  Serial.println(c5);
  c5 = c5.c_atan();
  Serial.println(c5);

  Serial.println("\n11. gonio csc sec cot acsc asec acot");
  c1.set(0.5, 0.5);
  c5 = c1.c_csc();
  Serial.println(c5);
  c5 = c5.c_acsc();
  Serial.println(c5);
  c5 = c1.c_sec();
  Serial.println(c5);
  c5 = c5.c_asec();
  Serial.println(c5);
  c5 = c1.c_cot();
  Serial.println(c5);
  c5 = c5.c_acot();
  Serial.println(c5);

  Serial.println("\n12. gonio hyperbolicus I ");
  c1.set(0.5, 0.5);
  c5 = c1.c_sinh();
  Serial.println(c5);
  c5 = c5.c_asinh();
  Serial.println(c5);
  c5 = c1.c_cosh();
  Serial.println(c5);
  c5 = c5.c_acosh();
  Serial.println(c5);
  c5 = c1.c_tanh();
  Serial.println(c5);
  c5 = c5.c_atanh();
  Serial.println(c5);

  Serial.println("\n13. gonio hyperbolicus II ");
  c1.set(0.5, 0.5);
  c5 = c1.c_csch();
  Serial.println(c5);
  c5 = c5.c_acsch();
  Serial.println(c5);
  c5 = c1.c_sech();
  Serial.println(c5);
  c5 = c5.c_asech();
  Serial.println(c5);
  c5 = c1.c_coth();
  Serial.println(c5);
  c5 = c5.c_acoth();
  Serial.println(c5);

  Serial.println("\n.. Complex done");

  uint32_t start = micros();
  for (int i=0; i<1000; i++)
  {
    c5 = c5.c_csc();
  }
  uint32_t dur = micros() - start;
  Serial.println(dur);
  Serial.println(one);
}

void loop()
{
}
//
// END OF FILE
//
/*  OUTPUT:
 *   
 Complex numbers test for Arduino: 0.1.09

1. Print Complex, set, real, imag
1.000 0.000i
10.000 -2.000i
3.000 0.000i
-10.000 4.000i
-5.000 -5.000i
0.000 0.000i
0.00
0.00

2. ==  != 
ok :)
ok :)
ok :)

3. negation - 
-10.000 2.000i
10.000 -2.000i
ok :)

4. + - 
13.000 -2.000i
13.000 -2.000i
7.000 -2.000i
7.000 -2.000i

5. * / 
30.000 -6.000i
90.000 -18.000i
30.000 -6.000i
10.000 -2.000i
10.000 -2.000i
10.000 -2.000i

6. assign += -= *= /=
20.000 -4.000i
23.000 -4.000i
13.000 -2.000i
10.000 -2.000i
96.000 -40.000i
288.000 -120.000i
30.000 -6.000i
10.000 -2.000i

7. phase modulus polar
10.000 -2.000i
10.20
-0.20
10.000 -2.000i

8. conjugate reciprocal
10.000 2.000i
10.000 -2.000i
0.096 0.019i
10.000 -2.000i

9. power: exp log pow sqrt sqr logn log10
96.000 -40.000i
-9166.244 -20028.609i
10.000 -2.000i
96.000 -40.000i
10.000 -2.000i
96.000 -40.000i
880.000 -592.000i
10.000 -2.000i
0.534 0.542i
10.000 -2.000i
1.009 -0.086i

10. gonio: sin cos tan asin acos atan
0.541 0.457i
0.500 0.500i
0.990 -0.250i
0.500 0.500i
0.404 0.564i
0.500 0.500i

11. gonio csc sec cot acsc asec acot
1.078 -0.912i
0.500 0.500i
0.950 0.240i
0.500 0.500i
0.839 -1.172i
0.500 0.500i

12. gonio hyperbolicus I 
0.457 0.541i
0.500 0.500i
0.990 0.250i
0.500 0.500i
0.564 0.404i
0.500 0.500i

13. gonio hyperbolicus II 
0.912 -1.078i
0.500 0.500i
0.950 -0.240i
0.500 0.500i
1.172 -0.839i
0.500 0.500i

.. Complex done
116805
1.000 0.000i
 
 
 */

and Inside the IDE window, click in the upper right Arrow to open a folder Inside this window that you call Complex.h . Copy and paste Complex.h from the original library inside Complex.h.

Click again in the upper right Arrow and add a new folder Inside Complex.ino that you call Complex.cpp . Copy and paste Complex.cpp from the original Library Inside Complex.cpp

Then compile, upload and run Complex.ino on your DUE.

I did a copy of the results at the end of Complex.ino above.

ard_newbie:
I tried to upload this Library this way, and I think it works (at least, I have no error at compile time):

Open a new sketch that you can call Complex.ino :

//

//    FILE: complex.ino
//  AUTHOR: Rob Tillaart
//    DATE: 2013-09-23
//
// PUPROSE: test complex math
//
// Serial.print(Complex) supported since 0.1.05

#include “complex.h”

void setup()
{
  Serial.begin(115200);
  Serial.print("\n  Complex numbers test for Arduino: “);
  Serial.println(COMPLEX_LIB_VERSION);
  Serial.println(”\n1. Print Complex, set, real, imag");

Complex c1(10.0, -2.0);
  Complex c2(3, 0);
  Complex c3(-10, 4);
  Complex c4(-5,-5);
  Complex c5(0, 0);

Serial.println(one);
  Serial.println(c1);
  Serial.println(c2);
  Serial.println(c3);
  Serial.println(c4);
  c3.set(0,0);
  Serial.println(c3);
  Serial.println(c3.real());
  Serial.println(c3.imag());

Serial.println("\n2. ==  != “);
  c5 = c1;
  if (c5 == c1) Serial.println(“ok :)”);
  else Serial.println(” fail :(");
  c5 = c1 + 1;
  if (c5 != c1) Serial.println(“ok :)”);
  else Serial.println(" fail :(");
  c5 = 3;
  if (c5 == 3) Serial.println(“ok :)”);
  else Serial.println(" fail :(");

Serial.println("\n3. negation - “);
  c5 = -c1;
  Serial.println(c5);
  c5 = -c5;
  Serial.println(c5);
  if (c5 == c1) Serial.println(“ok :)”);
  else Serial.println(” fail :(");

Serial.println("\n4. + - ");
  c5 = c1 + c2;
  Serial.println(c5);
  c5 = c1 + 3;
  Serial.println(c5);
  c5 = c1 - c2;
  Serial.println(c5);
  c5 = c1 - 3;
  Serial.println(c5);

Serial.println("\n5. * / ");
  c5 = c1 * c2;
  Serial.println(c5);
  c5 = c5 * 3;
  Serial.println(c5);
  c5 = c5 / c2;
  Serial.println(c5);
  c5 = c5 / 3;
  Serial.println(c5);

c5 = c1 / c2 * c2;
  Serial.println(c5);
  c5 = c1 * c4 / c4;
  Serial.println(c5);

Serial.println("\n6. assign += -= *= /=");
  c5 = c1;
  c5 += c1;
  Serial.println(c5);
  c5 += 3;
  Serial.println(c5);
  c5 -= c1;
  Serial.println(c5);
  c5 -= 3;
  Serial.println(c5);
  c5 *= c1;
  Serial.println(c5);
  c5 *= 3;
  Serial.println(c5);
  c5 /= c1;
  Serial.println(c5);
  c5 /= 3;
  Serial.println(c5);

Serial.println("\n7. phase modulus polar");
  Serial.println(c1);
  double m = c1.modulus();
  Serial.println(m);
  double p = c1.phase();
  Serial.println(p);
  c5.polar(m, p);
  Serial.println(c5);

Serial.println("\n8. conjugate reciprocal");
  c5 = c1.conjugate();
  Serial.println(c5);
  c5 = c5.conjugate();
  Serial.println(c5);
  c5 = c1.reciprocal();
  Serial.println(c5);
  c5 = c5.reciprocal();
  Serial.println(c5);

Serial.println("\n9. power: exp log pow sqrt sqr logn log10");
  c5 = c1.c_sqr();
  Serial.println(c5);
  c5 = c1.c_exp();
  Serial.println(c5);
  c5 = c5.c_log();
  Serial.println(c5);
  c5 = c1.c_pow(2);
  Serial.println(c5);
  c5 = c5.c_sqrt();
  Serial.println(c5);
  c5 = c5.c_sqr();
  Serial.println(c5);
  c5 = c1.c_pow(c2);
  Serial.println(c5);
  c5 = c5.c_pow(c2.reciprocal());
  Serial.println(c5);
  c5 = c5.c_logn(c4);
  Serial.println(c5);
  c5 = c4.c_pow(c5);
  Serial.println(c5);
  c5 = c5.c_log10();
  Serial.println(c5);

Serial.println("\n10. gonio: sin cos tan asin acos atan");
  c1.set(0.5, 0.5);
  c5 = c1.c_sin();
  Serial.println(c5);
  c5 = c5.c_asin();
  Serial.println(c5);
  c5 = c1.c_cos();
  Serial.println(c5);
  c5 = c5.c_acos();
  Serial.println(c5);
  c5 = c1.c_tan();
  Serial.println(c5);
  c5 = c5.c_atan();
  Serial.println(c5);

Serial.println("\n11. gonio csc sec cot acsc asec acot");
  c1.set(0.5, 0.5);
  c5 = c1.c_csc();
  Serial.println(c5);
  c5 = c5.c_acsc();
  Serial.println(c5);
  c5 = c1.c_sec();
  Serial.println(c5);
  c5 = c5.c_asec();
  Serial.println(c5);
  c5 = c1.c_cot();
  Serial.println(c5);
  c5 = c5.c_acot();
  Serial.println(c5);

Serial.println("\n12. gonio hyperbolicus I ");
  c1.set(0.5, 0.5);
  c5 = c1.c_sinh();
  Serial.println(c5);
  c5 = c5.c_asinh();
  Serial.println(c5);
  c5 = c1.c_cosh();
  Serial.println(c5);
  c5 = c5.c_acosh();
  Serial.println(c5);
  c5 = c1.c_tanh();
  Serial.println(c5);
  c5 = c5.c_atanh();
  Serial.println(c5);

Serial.println("\n13. gonio hyperbolicus II ");
  c1.set(0.5, 0.5);
  c5 = c1.c_csch();
  Serial.println(c5);
  c5 = c5.c_acsch();
  Serial.println(c5);
  c5 = c1.c_sech();
  Serial.println(c5);
  c5 = c5.c_asech();
  Serial.println(c5);
  c5 = c1.c_coth();
  Serial.println(c5);
  c5 = c5.c_acoth();
  Serial.println(c5);

Serial.println("\n… Complex done");

uint32_t start = micros();
  for (int i=0; i<1000; i++)
  {
    c5 = c5.c_csc();
  }
  uint32_t dur = micros() - start;
  Serial.println(dur);
  Serial.println(one);
}

void loop()
{
}
//
// END OF FILE
//
/*  OUTPUT:

Complex numbers test for Arduino: 0.1.09

  1. Print Complex, set, real, imag
    1.000 0.000i
    10.000 -2.000i
    3.000 0.000i
    -10.000 4.000i
    -5.000 -5.000i
    0.000 0.000i
    0.00
    0.00

  2. ==  !=
    ok :slight_smile:
    ok :slight_smile:
    ok :slight_smile:

  3. negation -
    -10.000 2.000i
    10.000 -2.000i
    ok :slight_smile:

13.000 -2.000i
13.000 -2.000i
7.000 -2.000i
7.000 -2.000i

    • /
      30.000 -6.000i
      90.000 -18.000i
      30.000 -6.000i
      10.000 -2.000i
      10.000 -2.000i
      10.000 -2.000i
  1. assign += -= *= /=
    20.000 -4.000i
    23.000 -4.000i
    13.000 -2.000i
    10.000 -2.000i
    96.000 -40.000i
    288.000 -120.000i
    30.000 -6.000i
    10.000 -2.000i

  2. phase modulus polar
    10.000 -2.000i
    10.20
    -0.20
    10.000 -2.000i

  3. conjugate reciprocal
    10.000 2.000i
    10.000 -2.000i
    0.096 0.019i
    10.000 -2.000i

  4. power: exp log pow sqrt sqr logn log10
    96.000 -40.000i
    -9166.244 -20028.609i
    10.000 -2.000i
    96.000 -40.000i
    10.000 -2.000i
    96.000 -40.000i
    880.000 -592.000i
    10.000 -2.000i
    0.534 0.542i
    10.000 -2.000i
    1.009 -0.086i

  5. gonio: sin cos tan asin acos atan
    0.541 0.457i
    0.500 0.500i
    0.990 -0.250i
    0.500 0.500i
    0.404 0.564i
    0.500 0.500i

  6. gonio csc sec cot acsc asec acot
    1.078 -0.912i
    0.500 0.500i
    0.950 0.240i
    0.500 0.500i
    0.839 -1.172i
    0.500 0.500i

  7. gonio hyperbolicus I
    0.457 0.541i
    0.500 0.500i
    0.990 0.250i
    0.500 0.500i
    0.564 0.404i
    0.500 0.500i

  8. gonio hyperbolicus II
    0.912 -1.078i
    0.500 0.500i
    0.950 -0.240i
    0.500 0.500i
    1.172 -0.839i
    0.500 0.500i

… Complex done
116805
1.000 0.000i

*/




and Inside the IDE window, click in the upper right Arrow to open a folder Inside this window that you call Complex.h . Copy and paste Complex.h from the original library inside Complex.h.

Click again in the upper right Arrow and add a new folder Inside Complex.ino that you call Complex.cpp . Copy and paste Complex.cpp from the original Library Inside Complex.cpp

Then compile, upload and run Complex.ino on your DUE.

I did a copy of the results at the end of Complex.ino above.

In the following link you will find the complex library that works on Arduino DUE, just read the ReleaseNote.txt. Your post @ard_newbie was very helpful to find this compilation mistake.

I noticed that the SERVO and IRREMOTE Librares were mentione earlier here in the Timers Forum for the Arduino DUE.

Has anybody solved the problem with the Conflict with Timer3 between the Servo and IRRemote Libs ?

  • I attempted to, but was not successful.

Anybody have a Solution ?

I have a library for the adafruit VC0706 camera.
The issue was the Due does not support soft serial. So I simply remove any reference to soft serial.
This may be the problem with many of the compatability issues.
I know there is a better way to do this, using “if architecture SAM3X”. But this worked for me.

Due_VC0706.cpp (10.8 KB)

Due_VC0706.h (3.36 KB)

i included 2 libraries of arduino due using (plc + schduler ) plc lib all functions was working properly but when adding shduler library the code complied normally but when i go to see result only first loop that fundtion in board due and stoped other loops don't work

Hi zahraali079.

First, to reach more people to help you, you should start a new tread.

Second, provide your code.

Regards. Nitrof

jlsilicon: I noticed that the SERVO and IRREMOTE Librares were mentione earlier here in the Timers Forum for the Arduino DUE.

Has anybody solved the problem with the Conflict with Timer3 between the Servo and IRRemote Libs ?

  • I attempted to, but was not successful.

Anybody have a Solution ?

Hi there @jlsilicon,

I do not know if it is already pertinent to answer a year-old question :| (sorry but it is a lot of time I have not had a look to this thread).

Well, the Servo library has a problem of compatibility due to its use of a given set of timers, you can tinker with it to use less timers, at least was like this last time I had a look to it.

In any case, I will advice you to take a look to pwm_lib (available at https://github.com/antodom/pwm_lib). A reason to develop this library was precisely to generate pwm signals for servos to use it instead the Servo library, as pwm_lib uses directly the PWM hardware modules available in DUE's ATSAM3X8E. So it does not use any timer for generating servo signals. This avoids this problem you mention completely.

I hope it helps.

Im using get.modifiers with a keyboard and everytime I press a key the output is 0 and not the proper value. Im new please help!!

I need arduino due library for connecting multiple TCA9548A 8 channel I2C expander. Does anyone have connected three TCA9548A in a single I2C line of Arduino due? Please help with this.

Hi ,

finally i got my "Yamaha THR10" (guitar amp, that can be configured via MIDI-SysEx) working with USBHost Library (arduino-libraries/USBHost) in conjunction with the " bbx10/USBH-Midi branch Due"-library

on "Arduino Due", but there were several problems to solve before:

Concerning library (arduino-libraries/USBHost):

USB-Enumeration works only, if Debug-outputs are enabled in USBHost.h

#define TRACE_USBHOST(x) x
//#define TRACE_USBHOST(x)

otherwise device is not detected.

Don't ask me why… Is it perhaps a timing problem, that is solved when a "printf" delays process at the right time? (Edit: in fact there are two places in USB.cpp, where short delays are necessary to get it work. You can leave TRACE_USBHOST(x) x like it was, if you add that two delays. Details at the end of this message!)

Has anyone had the same Problem with (native) USBHost - Library for Due?

Issues concerning library (bbx10/USBH-Midi branch Due):

Adding an "else if" in descriptor parsing

if( buf_ptr[5] == USB_CLASS_AUDIO && buf_ptr[6] == USB_SUBCLASS_MIDISTREAMING )
{ //p[5]; bInterfaceClass = 1(Audio), p[6]; bInterfaceSubClass = 3(MIDI Streaming)
isMidiFound = true; //MIDI device found.
isMidi = true;
}
//Yamaha THR10
else if( buf_ptr[5] == USB_CLASS_VENDOR_SPECIFIC && buf_ptr[6] == USB_SUBCLASS_MIDISTREAMING ) //Yamaha THR10
{
//p[5]; bInterfaceClass = 255(VENDOR), p[6]; bInterfaceSubClass = 3(MIDI Streaming)
isMidiFound = true; //MIDI device found.
isMidi = true;
}
else
{
#ifdef DEBUG
Serial.print("No MIDI Device\n");
#endif
// buf_ptr += total_length + 1;
// bConfNum = 0;
isMidi = false;
}
break;

Solving buffer problems:

always use (uint16_t) cast instead of (uint8_t) cast for epInfo[index].maxPktSize e.g.

// Extract Max Packet Size from device descriptor
epInfo[0].maxPktSize = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
quick and dirty change for buffersize, that works for THR10 (just a work around, no proper solution, i guess!!!):
if( isMidi )
{
if ((epDesc->bEndpointAddress & 0x80) == 0x80)
{
// Input
index = epDataInIndex;
epInfo[index].epAddr = (epDesc->bEndpointAddress & 0x0F);
//epInfo[index].maxPktSize = (uint16_t)epDesc->wMaxPacketSize;
epInfo[index].maxPktSize = (uint16_t)2048; //necessary for YAMAHA THR10
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].epAddr, UOTGHS_HSTPIPCFG_PTYPE_BLK, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 0, UOTGHS_HSTPIPCFG_PBK_1_BANK);
}
else
{
// Output
index = epDataOutIndex;
epInfo[index].epAddr = (epDesc->bEndpointAddress & 0x0F);
//epInfo[index].maxPktSize = (uint8_t)epDesc->wMaxPacketSize;
epInfo[index].maxPktSize = (uint16_t)2048; //necessary for YAMAHA THR10
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].epAddr, UOTGHS_HSTPIPCFG_PTYPE_BLK, UOTGHS_HSTPIPCFG_PTOKEN_OUT, epInfo[index].maxPktSize, 0, UOTGHS_HSTPIPCFG_PBK_1_BANK);
}

After that modifikations, i can send System-Exlusive Messages to THR10, like

uint8_t msg1[]= {0xF0,0x43,0x7D,0x30,0x41,0x30,0x01,0x01,0xF7}; //Lamp off
uint8_t msg2[]= {0xF0,0x43,0x7D,0x30,0x41,0x30,0x01,0x00,0xF7}; //Lamp on

that switches the light of the Guitar-Amp (just a test, more important, I can send sound-patches, that are created as a file before with the THR10-Editor on PC.)

This way I can build a foot-switch / pedal to change sound patches on the fly like in the THR10 foot switch project of

http://www.mehlbrandt.de/thr/thr_1

But this guy did it with an ordinary Arduino Uno and anUSB-Host Shield.

With the Due I can use the native USB-Host-Port, have got more memory and speed. I want to inject Samples to the THR10 with this footswitch as well, as it can also act as IN-/OUT Audio Interface.

EDIT: 1.) Add a delayMicroseconds(300ul); in function "USBHost::ctrlReq" where the following lines occure:

if (dataptr != 0)
{
if (direction)
{
// IN transfer
TRACE_USBHOST(printf("    => ctrlData IN\r\n");)

Add here---->              delayMicroseconds(300ul);  //necessary!! 275ul does not work!!

2) Add a delayMicroseconds(120ul); at start of function "USBHost::dispatchPkt"

uint32_t USBHost::dispatchPkt(uint32_t token, uint32_t hostPipeNum, uint32_t nak_limit)
{
uint32_t timeout = millis() + USB_XFER_TIMEOUT;
uint32_t nak_count = 0;
uint32_t rcode = USB_ERROR_TRANSFER_TIMEOUT;

---> add here: delayMicroseconds(120ul);  //NECESSARY!!  (100ul does not work!)

TRACE_USBHOST(printf("     => dispatchPkt token=%lu pipe=%lu nak_limit=%lu\r\n", token, hostPipeNum, nak_limit);)

Don't really know w h y this have to be done. But it does nor work otherwise.

;)

Just published a fast ILI9225 library for Arduino Due.

https://github.com/martinzw/ILI9225_Due

It uses DMA and works much faster than the well known TFT_22_ILI9225 library.

It is an adaption/mixture of ILI9341_Due and ILI9225_t3.

Hello Your help please. I have an ARDUINO DUE card and I am using the NexDualStateButton buttons to be able to program with an NEXTION screen NX8048K070_011C but the problem is that when compiling the following comes up: 'NexDSButton' does not name a type, even using the example that comes in the library (CompDualStateButton).

antodom: Hi all,

This post is just to anounce that I have developed a library for the DUE which takes advantage of several features of the Timer Counter (TC) modules available in Atmel's ATSAM3X8E.

The name of the library is tc_lib and it is openly available at:

https://github.com/antodom/tc_lib

In its initial operative version the library provides two kind of objects:

  • Capture objects. With these objects you can measure the period and pulse (duty) of a typical digital signal, like a PWM signal. In fact, the example provided measure the signal generated with analogWrite().
  • Action objects. These objects allow to associate a callback function to any of the TC channels (you have nine in total), such that the function its called with the period you establish. The resolution of the period is in microseconds.

You have available examples using both types of objects, I hope the examples are self-explaining.

More info about tc_lib in https://github.com/antodom/tc_lib.

Drop me a line if you have any question or interest.

Hi. Thanks a lot for this interesting library. I am trying to use "action_tc0" mode to measure the time (in us) which a part of my code (a while loop which digitalread a pin) takes to run, something similar to what micro() function does (which uses TC0), but I am looking for a more precise implementation. What is the best way to do this? I have tried to use the counter inside the set_led_action, but it just always returns 2! whereas when using micros, it returns correct times (but with a resolution of around 2us, I want 1us)

but it just always returns 2!

Please provide codeof what you have right now...

Regards.

Nitrof

Hi, here is the code, some modification to original code, a sinusoidal signal is given to AD1 pin, which digitalRead used to read that, the aim is to measure the time that signal is high, using timer instead of the micro function.

TC3ActionTest.ino (2.58 KB)

Hi there @obihavemojo,

If you want a 1 usec period, CALLBACK_PERIOD should be 100, not 1000000. Take into account that tc_lib uses as time unit for the period hundreths of usecs. (1e-8 secs.)

Best.

antodom:
Hi there @obihavemojo,

If you want a 1 usec period, CALLBACK_PERIOD should be 100, not 1000000. Take into account that tc_lib uses as time unit for the period hundreths of usecs. (1e-8 secs.)

Best.

Hi, thanks a lot, that actually works correctly, and jitter is nicely very low. That’s for generating a pulse every 1us.

Still, from the code I had attached, I need to use this timer to measure the time it takes for the while loop that reads the digital pin which is fed by a constant frequency signal, for example, a 200 kHz square or sine wave, the counter value stays the same (no measurement of the past time) when I check the action_ctx.counter before and after the while loop; and it does not change when I change the frequency of the input, for example, double it, or halve it.
Maybe reading a digital pin mess up the timer interrupts, not sure.

Regards