# Problems with Arduino DUE

**URL:** <https://forum.arduino.cc/t/problems-with-arduino-due/1133024>\
**Category:** Due\
**Created:** [May 31, 2023, 12:10pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024 "2023-05-31T12:10:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![traaack](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@traaack](https://forum.arduino.cc/u/traaack)\
**Post date:** [May 31, 2023, 12:10pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/1 "2023-05-31T12:10:25Z")

</div>

So, I have made one project using a MAX 7219 (the led display 8x32) on my Arduino UNO, but it stopped working and I wanted to continue on a Arduino Due that I found. The problem is, the code utilizes the pins SCK, MOSI and SS ( CLOCK, DATA PIN and CHIP SELECT), that were the pins 13, 11 and 10 on the Arduino UNO.

Checking the pinouts of the Arduino DUE in some other posts, I have found that the SCK and MOSI are some pins in the middle of the board, where I need to use female jumpers to get them. The problem is, those pins doesn't have a "number" for then, they are just the SCK and MOSI itself. On the previous code I defined they by "#define CLK\_PIN 13", how can I adjust the code so I can get that pinout?

I'm new to the forum and Arduino itself, so if I am saying things wrongs sorry for my misinformation... and for my bad english as well

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [May 31, 2023, 12:27pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/2 "2023-05-31T12:27:41Z")

</div>

> [@traaack](#):
>
> Checking the pinouts of the Arduino DUE in some other posts, I have found that the SCK and MOSI are some pins in the middle of the board, where I need to use female jumpers to get them

The central ISP\SPI connector is where the DUE SPI pins are.

Its also the location of the SPI pins on the UNO and Mega.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 31, 2023, 12:40pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/3 "2023-05-31T12:40:16Z")

</div>

> [@traaack](#):
>
> I have made one project using a MAX 7219 (the led display 8x32) on my Arduino UNO, but it stopped working and I wanted to continue on a Arduino Due that I found

You want to do this to figure out if the Uno failed or the max7219 failed? If the max7219 works with the Due you will know that the Uno has failed?

Can you test the Uno another way? Can you upload the blink sketch to it and have the on-board led flashing, for example?

> [@traaack](#):
>
> the code utilizes the pins SCK, MOSI and SS ( CLOCK, DATA PIN and CHIP SELECT), that were the pins 13, 11 and 10 on the Arduino UNO

What you need to find out is whether the code uses the hardware SPI of the Uno or is using software SPI ("bit-banging") but by coincidence is using the same pins as are normally used for hardware SPI.

If it is software SPI, then you can use any ordinary digital pins on the Due.

> [@traaack](#):
>
> On the previous code I defined they by "#define CLK\_PIN 13",

This makes me suspect that your code is using software SPI. It would not be necessary to define that pin if hardware SPI was used.

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [May 31, 2023, 12:46pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/4 "2023-05-31T12:46:26Z")

</div>

The UNO is a 5V Logic device and the DUE is a 3.3V logic device.

Can the MAX7219 be used on the 3.3V DUE ?

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 31, 2023, 12:54pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/5 "2023-05-31T12:54:05Z")

</div>

> [@srnet](#):
>
> Can the MAX7219 be used on the 3.3V DUE

In theory no. The supply voltage is 4.0-5.5V and a logic high signal must be above 3.5V according to the datasheet.

In practice, I have had max7219 working fine with esp8266 which are also 3.3V. But it is not guaranteed to work.

A logic level shifter such as 74hct125 might be needed.

---

<div class="post-metadata">

**Author:** ![traaack](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@traaack](https://forum.arduino.cc/u/traaack)\
**Post date:** [May 31, 2023, 1:03pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/7 "2023-05-31T13:03:11Z")

</div>

> [@PaulRB](#):
>
> You want to do this to figure out if the Uno failed or the max7219 failed? If the max7219 works with the Due you will know that the Uno has failed?
> 
> Can you test the Uno another way? Can you upload the blink sketch to it and have the on-board led flashing, for example?

I actually wanted to continue the project on the DUE, because the capacity of the UNO was basically at its limit... But after the last upload on the code the UNO began to never upload anything at all and I am pretty worried about it. But the UNO was working perfectly fine with the code before.

On the Due while I was trying to make the code work on it, the max7219 is sometimes with all the led's off, sometimes all on, or just some 8x8 at a time. I don't know actually if the problem is on the code (and saying the right things abot the 3 pins - SCK, MOSI and SS) or the max7219, but before trying it on Due it was perfectly fine.

> [@PaulRB](#):
>
> What you need to find out is whether the code uses the hardware SPI of the Uno or is using software SPI ("bit-banging") but by coincidence is using the same pins as are normally used for hardware SPI.
> 
> If it is software SPI, then you can use any ordinary digital pins on the Due.

Ohhh understood, I did not know there was a difference there, the parts of using those pins of the display specifically I got from another code, so I assumed it was necessary to be those pins (the original code is actually written as "#define CS\_PIN 10 // or SS", so I assumed it was the SS of the board that you are using. Is there a way for me to know if I am using a software SPI or the hardware SPI? I am just know learning about those and it's quite interesting.

> [@PaulRB](#):
>
> This makes me suspect that your code is using software SPI. It would not be necessary to define that pin if hardware SPI was used.

Okay, I am gonna try using on 3 "random" pins on the DUE and see if it is gonna work.

Thankss a lot for the response

---

<div class="post-metadata">

**Author:** ![traaack](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@traaack](https://forum.arduino.cc/u/traaack)\
**Post date:** [May 31, 2023, 1:11pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/8 "2023-05-31T13:11:57Z")

</div>

> [@PaulRB](#):
>
> In theory no. The supply voltage is 4.0-5.5V and a logic high signal must be above 3.5V according to the datasheet.
> 
> In practice, I have had max7219 working fine with esp8266 which are also 3.3V. But it is not guaranteed to work.
> 
> A logic level shifter such as 74hct125 might be needed

Ohh I did not think of that, maybe that could be the problem cause the matrix even with everything on it sometimes experienced some instability.

Maybe that would fix the problem but I am still gonna try some other stuff and see if I can maybe make the code "kinda work" on it first  
Thanks so much for the help

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [May 31, 2023, 1:28pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/9 "2023-05-31T13:28:09Z")

</div>

> [@traaack](#):
>
> Is there a way for me to know if I am using a software SPI or the hardware SPI?

It would be clear to us all if you posted the code.

---

<div class="post-metadata">

**Author:** ![traaack](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@traaack](https://forum.arduino.cc/u/traaack)\
**Post date:** [May 31, 2023, 1:57pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/10 "2023-05-31T13:57:04Z")

</div>

The only part of the code that actually uses these defined PINs is the mx and P below, so I don't know if they have a bigger influence on the rest of it just by being defined (I believe they don't have right??).

This define thing I got from another code so I don't know if it could be done other way or if it must be this way

Plus, I am not sure if the voltage thing is a problem because on the Arduino Due there is a pin (the 5V pin) that has a 4.5/4.8 DC on it (I used a multimeter) , so it has a voltage pretty similar right?

```arduino
#include <MD_MAX72xx.h>
#include <MD_Parola.h>

#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 4
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS

MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

```

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 31, 2023, 5:41pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/11 "2023-05-31T17:41:54Z")

</div>

> [@traaack](#):
>
> ```arduino
> #define CLK_PIN 13 // or SCK
> #define DATA_PIN 11 // or MOSI
> 
> ```

These definitions are not used anywhere in your code. Try searching for them and you will see. You can delete those lines, they have no effect on the code.

This must mean that the library is using hardware SPI. So you should use hardware SPI pins on the Due also. You don't need to update the code because they are different pins on the Due.

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [June 1, 2023, 8:12am UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/12 "2023-06-01T08:12:49Z")

</div>

> [@traaack](#):
>
> On the previous code I defined they by "#define CLK\_PIN 13"

If you want to use the SPI pins on the ISP connector, and you want new names for them, you can do:

```arduino
#define CLK_PIN SCK
#define SPIOUT_PIN MOSI // or whatecer...
#define SPIIN_PIN MISO

```

(the standard names SCK/MOSI/MISO are defined in the appropriate "variant.h" file.)

---

<div class="post-metadata">

**Author:** ![SupArdu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/supardu/32/1089208_2.png) [@SupArdu](https://forum.arduino.cc/u/SupArdu)\
**Post date:** [November 10, 2023, 3:44pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/13 "2023-11-10T15:44:59Z")

</div>

There is an error in variant.h for Due:

```arduino
#define PIN_SPI_SS0 (77u)
#define PIN_SPI_SS1 (87u)
#define PIN_SPI_SS2 (86u)
#define PIN_SPI_SS3 (78u)
...
#define BOARD_SPI_SS0 (10u)
#define BOARD_SPI_SS1 (4u)
#define BOARD_SPI_SS2 (52u)
#define BOARD_SPI_SS3 PIN_SPI_SS3
#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3

```

On the Due board there is no pin 78, nor 77, 86, 87!  
If you use function calls from the SPI library you have to choose those calls with chip select pin as first parameter, e.g.

```arduino
int cs_pin = 4; // or 
...
SPI.begin(cs_pin);
SPI.transfer(cs_pin, 0xFF);

```

never use:

```arduino
SPI.begin();
SPI.transfer(0xFF);

```

because without cs\_pin as parameter BOARD\_SPI\_DEFAULT\_SS will be used as chip select.

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [November 10, 2023, 10:45pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/14 "2023-11-10T22:45:18Z")

</div>

> [@SupArdu](#):
>
> On the Due board there is no pin 78, nor 77, 86, 87!

Are you sure? On some boards, pins will have multiple "Arduino Pin Numbers", depending on what function is being demanded of them. Since the g\_aPinDescription type only lets a pin have a single function, usually.

For instance, looking at variant.cpp, there is an entry for "pin 86":

```arduino
  // 86 - SPI CS2
  { PIOB, PIO_PB21B_SPI0_NPCS2, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TI

```

which is an alias of pin 52 (also on PB21):

```arduino
  { PIOB, PIO_PB21, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 52

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 8, 2024, 10:45pm UTC](https://forum.arduino.cc/t/problems-with-arduino-due/1133024/15 "2024-05-08T22:45:26Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
