Go Down

Topic: Arduino Due libraries (official and 3rd party) (Read 148334 times) previous topic - next topic


looks and sounds as if the DUE finally has been abandoned by Arduino.cc (or at least is  treated more than stepmotherly)

:( :(


Greetings to all.
@ josheeg i want to find eigen values and eigen vector of complex matrix in arduino. And don't know how to do that . I have downloaded your eigen library and also the one that is available at github,,

Actually i am converting a matlab code to arduino . I am using arduino due board . Below is the sample code of matlab that i want to convert in arduino
 [V,Dia] = eig(Rxx);
[Y,Index] = sort(diag(Dia));
EN = V(:,Index(1:6-1));

Rxx is complex matrix of 6x6. I have created this matrix in arduino using complex.h library. Now i have to find eigen values and eigen vectors of this matrix. So what should i do ,can any one help?


currently the implementation of the USB.task is really weird, keyPressed and keyReleased don't return anything and it's totally osbscured how and when they do either or anything meaningful,
currently it's not even possible to indicate if a key was hit at all or not (like provided by kbhit() ),
usb.Task has to be called repeatedly but then blocks program execution intermediately and repeatedly for many seconds (which is unconscionable in the main loop() but shockingly also hinders different additional Scheduler multitasking threads ).
I recently began investigating USB host on Due. The keyboard example works OK here. There is an OTG to host cable on the native port for the keyboard. The programming port is connected to a PC. External power is plugged into the barrel connector. The keyboard does not work without external power.

IDE 1.6.6, Due board package 1.6.6., Due USB Host library 1.0.4. Latest versions of everything.

I wish there were another non-HID example because the ADK example is very confusing. I hooked an Android tablet but nothing happens on the Due or the tablet. I guess I have to dig in and find out what app, if any, is required on the Android side. And turn on trace debug.

Some keyboard output.

Program started
Pressed:   key:20 mod:0 => q
Released:  key:20 mod:0 => q
Pressed:   key:26 mod:0 => w
Released:  key:26 mod:0 => w
Pressed:   key:8 mod:0 => e
Released:  key:8 mod:0 => e
Pressed:   key:21 mod:0 => r
Released:  key:21 mod:0 => r
Pressed:   key:23 mod:0 => t
Released:  key:23 mod:0 => t


Dec 20, 2015, 01:28 am Last Edit: Dec 20, 2015, 01:34 am by pistolero992000
Hi Guys,

I'm trying to implement the awesome TVOut library on the arduino due....

my results so far... https://youtu.be/3PaF-g1nPGE

when I have the library working I'll upload it, for now, I think I'm getting somewhere...

by the way... this is the Sync Generation.... you may say it's like Grug from The Croods... but if you saw the video, it's working nice so far ;)

Code: [Select]
volatile int syncON, syncOFF;
volatile int LineCount;
char v1;
int i, r;
int vLines;

#define HRes 744
#define VRes 240
#define ScreenRatioCorrection (VRes * 53 / 18) / HRes
const float AspectRatioY = 4301075 / 10000000;
#define LinesToWait 10
#define ArraySize int(HRes/8 * VRes)
#define ScreenTop 0
#define ScreenBot VRes - 1

#define NOP __asm__("nop\n\t")
#define NOP100 NOP10;NOP10;NOP10;NOP10;NOP10;NOP10;NOP10;NOP10;NOP10;NOP10

#define NOPPrePixels NOP100;NOP100;NOP100;NOP100;NOP//;NOP//;NOP//;NOP;NOP//;NOP//;NOP//;NOP  //NOPLineSync
#define NOPPixel400 NOP;NOP;NOP;NOP;NOP;
#define NOPPixel640 NOP//;NOP

void setup() {
  pinMode(2, OUTPUT);
  pinMode(23, OUTPUT);
  pinMode(3, OUTPUT);   // port B pin 25
  analogWrite(3, 255);  // sets up some other registers I haven't worked out yet
  REG_TC2_WPMR = 0x54494D00; // enable write to registers
  //               33222222222211111111110000000000
  //               10987654321098765432109876543210
  REG_TC2_CMR1 = 0b00000000000010011100010000000000;
  // 1/50/625*84000000 - 1 = 2688: 64uS PER LINE /PAL STD
  // 1/60/525*84000000 - 1 = 2669.5: 63.55uS PER LINE /NTSC STD
  REG_TC2_RC1 = 2670;
  REG_TC2_RA1 = 0;  // PWM value 4.7uS
  REG_TC2_CCR1 = 0b101;  // start counter
  REG_TC2_IER1 = 0b00010000; // enable interrupt on counter=rc
  REG_TC2_IDR1 = 0b11101111; // disable other interrupts
  NVIC_EnableIRQ(TC7_IRQn); // enable TC7 interrupts
  NVIC_SetPriority(TC7_IRQn, 0); //sets Interrupt Priority to top

  LineCount = 0;
  syncON = ~1 << 25; // PIOB.25-->Pin D2 on the board
  syncOFF = 1 << 25;

  draw_line(0, 0, 0, VRes - 1, 1);
  draw_line(0, VRes - 1, HRes - 1, VRes - 1, 1);
  draw_line(HRes - 1, VRes - 1, HRes - 1, 0, 1);
  draw_line(HRes - 1, 0, 0, 0, 1);

  draw_line(HRes / 2 - 1, 0, HRes / 2 - 1, VRes - 1, 1);
  draw_line(0, VRes / 2 - 1, HRes - 1, VRes / 2 - 1, 1);

  draw_circle(HRes / 2 - 1, VRes / 2 - 1, 240, 1, 0);
  DrawEllipse(HRes / 2 - 1, VRes / 2 - 1, 100, 50, 1, 0);
  draw_circle(HRes / 2 - 1, VRes / 2 - 1, 50, 2, 1);


void TC7_Handler()  // Interrupt every 64.07uS (PALSTD)
  long dummy = REG_TC2_SR1; // vital - reading this clears some flag otherwise you get infinite interrupts start the Horizontal sync pulse
  // **************************
  // ***** Sync Generation ****
  // **************************
  PIOB->PIO_ODSR = syncON;
  if (LineCount <= ScreenBot) NOPLineSync; // Generates the 4.7uS 0V sync pulse
  if (LineCount == 248) {   syncON = 1 << 25;    syncOFF = ~1 << 25;    NOPLineSync;  }
  if (LineCount == 251) {   syncON = ~1 << 25;    syncOFF = 1 << 25;    NOPLineSync;  }
  if (LineCount == 263) {    LineCount = 0;    NOPLineSync;  }
  if (LineCount <= (ScreenBot) && LineCount >= (ScreenTop + LinesToWait)) {    i = (LineCount - LinesToWait) * HRes / 8;  }
  // **************************
  // ***** Sync Generation ****
  // **************************

  if ((LineCount) <= (ScreenBot) && (LineCount) >= (ScreenTop + LinesToWait))
    for (int j = 0; j < int(HRes / 8); j++) {
      v1 = screen[i + j] ;
      PIOA->PIO_ODSR = (v1 & 128) <<  7;//NOPPixel640;  // PIOA.14-->Pin D23 on the board
      PIOA->PIO_ODSR = (v1 &  64) <<  8;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &  32) <<  9;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &  16) << 10;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &   8) << 11;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &   4) << 12;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &   2) << 13;//NOPPixel640;
      PIOA->PIO_ODSR = (v1 &   1) << 14;//NOPPixel640;
    PIOA->PIO_ODSR = ~1 << 14;


I thank Stimmer for the Due Timer and the TVOut library designer for this project, they were the inspiration...

Next... NTSC Video overlay (Video Experimenter @ https://nootropicdesign.com/ve/) ;)

this is the Arduino MEGA overlay using Video Experimenter concept :https://youtu.be/frtSf0sggEk


Dec 20, 2015, 03:48 pm Last Edit: Dec 21, 2015, 09:10 am by ArthurD
Program started
Pressed:   key:20 mod:0 => q
Released:  key:20 mod:0 => q
Pressed:   key:26 mod:0 => w
Released:  key:26 mod:0 => w
Pressed:   key:8 mod:0 => e
Released:  key:8 mod:0 => e
Pressed:   key:21 mod:0 => r
Released:  key:21 mod:0 => r
Pressed:   key:23 mod:0 => t
Released:  key:23 mod:0 => t
this is not how it is expected to work.

It should work by stdio.h and possibly conio.h functionality like, e.g.
Code: [Select]
char sbuf[20];
while(1) {
     if kbhit() {
        int c = getch();
        // or perhaps:
        // sprintf (sbuf, "%c", (char)c);
        // Serial.print(sbuf);


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:


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 all again :)

This is to announce the publication of a library which abstract the eight PWM channels available in Arduino DUE's ATSAM3X8E microcontroller.

The name of the library is pwm_lib, and is openly available at: https://github.com/antodom/pwm_lib.

Each ATSAM3X8E PWM channel can be used to generate a completely independent PWM signal directly on hardware. The motivation to develop this library was two fold. First, the current limitation of the Arduino standard library where it is not possible to change the PWM output period of the PWM signals generated using function analogWrite(). And second, to have a library for servos directly supported by the hardware, therefore, "lighter", in terms of code generated and computational load, than the Servo library available in the Arduino standard library.

The library provides two kind of objects associated with each PWM channel: pwm and servo objects. As those objects abstract the PWM channels available on the micro controller, using pwm_lib you can use, at most, eight independent pwm_lib objects in your application, each one with its own PWM characteristics (PWM signal period and pulse duration). In its current version, the maximum period for PWM signals you can get using pwm_lib is a period of 0.798915048 seconds (minimum frequency of 1.251697539 Hz).

Two examples comes with pwm_lib to illustrate its use: basic_test.ino and servo_test.ino, who illustrate respectively the use of pwm and servo objects. Example basic_test.ino uses two PWM objects for generating two independent PWM outputs with different PWM characteristics (period and duty). Example servo_test.ino uses a servo object to generated a PWM output for a typical servo.

More details about pwm_lib in https://github.com/antodom/pwm_lib.

And, if in any doubt, drop me a line.

I hope it helps.


Which library you would recommend to connect an ESP8266 WiFi module? I vote for ITEADLIB_Arduino_ESP8266


@ antodom: thank you for the pwm_lib...

I have two little question:

1) is it possible to set "dynamically" the frequency/period as seem we can do with the duty cycle?

I mean a method "pwm_pinX.set_period(period_value);" like "pwm_pinX.set_duty(duty_value);"

I would like to make something like a polyphonic synthesizer and be able to manage the start-stop/freq/duty for every voice.

2) Are all the registers/counters used 16 bit, right?


Hi there @pjeve,

For changing the frequency, use pwm_object.stop() first, and then pwm_object.start(period,duty), where you can set a new period.

In relation to your second question, the PWM counter is a 16 bit counter according to ATMSAM3X8E datasheet, but the resolution depends on the period you establish. In fact, due to that, in pwm_lib you specify the duty in time units, not in internal counter ticks. You can find out the number of counter ticks using function pwm_core::tick_time() using as argument, the returned value of pwm_core::find_clock() for the period you want to use (both functions are in pwm_defs.h).




For LCD Display with port expander PCF8574 library


For LCD display with menu navigation library




now what about a reasonable keyboard HID lib ?
when will there be finally one ?

this is not how it is expected to work.

It should work by stdio.h and possibly conio.h functionality like, e.g.
Code: [Select]
char sbuf[20];
while(1) {
     if kbhit() {
        int c = getch();
        // or perhaps:
        // sprintf (sbuf, "%c", (char)c);
        // Serial.print(sbuf);

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131