Go Down

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


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.


Mar 31, 2019, 06:10 pm Last Edit: Mar 31, 2019, 10:30 pm by MartinZ Reason: new information after done some research.
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

Code: [Select]

#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

Code: [Select]

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;
#ifdef DEBUG
Serial.print("No MIDI Device\n");
// buf_ptr += total_length + 1;
// bConfNum = 0;
isMidi = false;

Solving buffer problems:

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

Code: [Select]

// 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);
// 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
Code: [Select]

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


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.

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

Code: [Select]

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"

Code: [Select]

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;

---> 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.



May 10, 2019, 12:48 am Last Edit: Jun 04, 2019, 07:33 am by MartinZ Reason: Link for Library
Just published a fast ILI9225 library for Arduino 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.


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).


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. 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...




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


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.)


Go Up