Arduino Due "Power-Ups" © GPL3+

Proof of concept aimed to "unlock" an RTC, an EEPROM and a few other things.

  • 749 views
  • 0 comments
  • 0 respects

Components and supplies

Ard due
Arduino Due
×1
USBasp Programmer
There are anyways several solutions to upload the firmware on the 16u2
×1
Ultra ATA Ribbon Cable
Lots of lots of thin wires
×1
2k7 0603 size resistor
×3
Around ~6V Zener diode
If you want to fit this component, a bit of electronic investigation must be made, load it with 12V through a 10Meg resistor and read the voltage across it with a digital multimeter, if more than 3.3V it's good
×1
Fox electronics nc26lf 327. image
32.768 kHz Crystal
×1
Kemet c315c220k1g5ta image
Capacitor 22 pF
×2

Necessary tools and machines

09507 01
Soldering iron (generic)
Use one with a good small tip, and ensure that ground wire is earthed
Thin and GOOD solder wire (don't buy here)
Good solder wire is a mystical subject
Cutter with a fresh blade
LOL

Apps and online services

About this project

Introduction

First of all, these are not ideas of mine. I just wanted to pack them all in one project, polish it up a bit, and publish it. I wanted to let Due owners know that there are features on this board that they may not know about; some of these features can be obtained with external cheap peripherals.

If you don't feel "ice bold" with micro-soldering or you want avoid risking your Due, DON'T MODIFY YOUR BOARD!!!

Subjects covered here:

  • MOSFET bug on V02 boards
  • Absence of slow quartz on phony boards
  • VDDBU mod
  • NRST mod
  • ATMega16u2 functionalities\mod
  • Overclock

V02 vs V03 

The V02 board is distinguishable from the newer V03 by the orientation of the MOSFET depicted below. If the two pins on the same side of the MOSFET (gate and source) point to Pin 13 of the board, it's a V02, otherwise it's a V03.

==MOSFET Resister Mod

My board is the elder one, called V02. Mine is actually a counterfeit, the V02 board suffers from random mis-boots and it hangs at boot sometimes. This is due to the fact that the MOSFET that pulls up the erase pin of the sam3x8e have its gate briefly left floating during the ATMega16u2 startup, actually randomizing the MOSFET closing. This lasts very briefly, not enough to erase the MCU but it can "go crazy." The solution is to put a 10k (2k7 works as well) resistor across the gate and the source of the MOSFET, letting it stay off if left undriven.

==Slow Crystal

Counterfeits or maybe clones usually don't have the 32'768Hz quartz. This crystal is not necessary almost for anything, but it can be used for letting the onboard RTC of the sam3x8e run, or to have a slower clock source, or to let the "Real Time Timer" run at precise speed (unlike with the on-chip RC oscillator). There's also a neat library for the RTC if you don't want to go crazy over the 1500 pages datasheet of the sam3x8e. You should fit a watch crystal with possibly a known capacitance load of 12.5pF. This component can be found in every classic "el cheapo" clock. This kind of crystal has a better stability than lower capacitance ones, and is easily available on the market. Along with the crystal of 12.5pF, you must fit two small capacitance caps from the two crystal pads to a suitable GND spot. They must be of around 18pF each.

Soldering the crystal case is a bad practice, but it will avoid potential noise. Scratch the spot of the case that you want to tin with a cutter, and be fast at soldering. Don't let it heat up "supernova style," and maybe assemble the three components before placing them on the board.

==The VDDBU Mod

To use this mod you need the NRST mod also.

The Due isn't intended to be put to sleep, you should power it or turn it completely off, but sleep features as well as "semi-powered" features are present on the sam3x8e, like the "Backup Domain". The main MCU has a VDDBU pin (number *52 of the chip) that can be supplied with 3V from a small battery (CR2032 ?) to let some internal peripherals stay powered, even if there's no VCC supplied, these peripherals are:

  • RTC (time, calendar, a bunch of alarms\interrupts\wakeups)
  • GPBRs (eight 32bit NVRAM General Purpose Backup Registers for your settings and stuff)
  • RTT (Real Time Timer; actually a 32bit counter with some interrupts)
  • SUPC (Supply Controller; we don't care)

Connections

To be able to connect a battery to this pin, we must first isolate it from the 3.3V net. The track to cut looks different from V02 to V03, but it's basically the same. You must cut the pits near the chip, because there are other components connected to the 3.3V line; but you must leave a portion of track to be able to solder a thin wire (to avoid soldering on the MCU pin).

Then our wire can take a tour on the board, pass through a hole and be connected to the "spare" pin near IOREF. I've also added a Zener, pointing from GND to VDDBU, to avoid discharges on the "micropower" pin. I've used an around 6V one that at 4V draws 1uA.

The VDDBU pin will constantly draw 2-4uA from the battery, plus leaks, this will let the RTC run on a CR2032 for years.

If you are questioning yourself about where to find those super-thin wires, just use a PATA IDE hard drive cable, the type used after 1998 (thinner wires).

Add Jumper

I don't suggest to place caps in parallel or "twin Y" schottky diodes in series, because this is discouraged by RTC manufacturers. Instead, I used a Dupont male jumper from IOREF to VDDBU in case I don't want to "backup", this is needed because if you don't power the VDDBU pin the board will not work.

GPBRs

The GPBRs are offensively easy to use.

uint32_t a = 0xFFFFFFFF;
uint32_t z = GPBR->SYS_GPBR[i];
GPBR->SYS_GPBR[i] = a;

"i" is from 0 to 7. That's it, just like variables.

The RTC can be used with the RTCDue library. The RTT, I don't know, these are general pourpose features; read the datasheet. :)

==The NRST Mod

If you make just the VDDBU mod, you'll come up with a problem. The 16u2 will reset the sam3x with every excuse; for doing so, it will assert low the NRSTB pin (pin *47 of the chip); with this it will reset ANYTHING on the sam3x8e except the flash. There's another reset pin on the package (yes, more than one), the NRST (pin *69); this reset pin doesn't touch the backup domain, so the VDDBU mod makes sense now. You need to cut the line that leads to NRSTB.

Then connect the reset net to NRST. I did it through a 2k2 resistor, but I thought that there was a 1k resistor from the 16u2 to the reset net, but it's instead 10k. The possible pull-down made by NRST will not cause a problem if you don't fit a resistor (NRST pull-down is capable of little current), however, you may fit another 2k7 resistor.

Beware that when uploading with the programming port, the sketch will not reboot on its own if you use NRST. You need to repower the board (or mod leaving the reset track to NRSTB still leading to the button and press it after upload).

==The ATMega16u2 "Awakening" Mod

Why use the ATMega16u2 just for uploading and serial monitor when it's a microcontroller on its own? It can be used, for example, as GPIO or for its EEPROM, feature that the sam3x8e doesn't have.

We'll gain three features directly on the sketch loaded on the sam3x8e:

  • Read and write the 512 bytes EEPROM on the 16u2
  • Use 6 of its GPIOs (the good ol' 20-40mA 5V pins like the Uno board)
  • Disable\re-enable auto-reset on programming port
The software used here was taken online and heavily modified to my preferences. For example, you now don't need to disable the system in case it's not used or you don't need to open serial monitor to let the two chips communicate. The "GPIO" and "autoreset" features were added.

This system isn't "bombproof," but it should work well if you don't stress it too much with speed. Also, consider it in "beta" stage.

Hardware Mod

First let's take a look at the hardware mod. The sam3x8e must say to the 16u2 to listen on the "Serial" port for particular instructions, for doing so an "assert" wire must be fitted. The cleanest way is to solder a wire from an unused pin on the sam3x8e to the header pad near the 16u2, but a standard pin can also be used if you don't want to microsolder the sam3x, but you'll have a wire hanging around.

This uses pin *93 (PC11):

Then it goes to PB7 of the 16u2 (this pin is hardcoded in the new firmware for this task), it's better to fit a resistor to avoid pin conflicts, let's say 2k7 (again).

I've used the PB7 pad for both passing the VDDBU wire and 16u2 asserting, cool uh? :)

Software Mod

Then the software part of the mod. You need a way to program the 16u2. There are different ways, all documented online. I've used an USBasp programmer, but you'll have a big whoop of problems for installing drivers on Win10 (you must disable driver signature check at boot). Burn the modified firmware provided here on the 16u2, place the library into the IDE and now you are ready to go (read examples first).

This mod is annoyance free, it means that you can happily forget about it and use your Due as usual.

==Overclock

Overclock is possible and quite easy to perform, it's just a reconfiguration to add on top of the sketch:

#define SYS_BOARD_PLLAR (CKGR_PLLAR_ONE | CKGR_PLLAR_MULA(18UL) | CKGR_PLLAR_PLLACOUNT(0x3fUL) | CKGR_PLLAR_DIVA(1UL))
#define SYS_BOARD_MCKR ( PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
//Set FWS according to SYS_BOARD_MCKR configuration
EFC0->EEFC_FMR = EEFC_FMR_FWS(4); //4 waitstate flash access
EFC1->EEFC_FMR = EEFC_FMR_FWS(4);
// Initialize PLLA to 114MHz
PMC->CKGR_PLLAR = SYS_BOARD_PLLAR;
while (!(PMC->PMC_SR & PMC_SR_LOCKA)) {}
PMC->PMC_MCKR = SYS_BOARD_MCKR;
while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {}
// Re-initialize some stuff with the new speed
SystemCoreClockUpdate();

On the first line there's "18UL," this tells the PLL what multiplier value to use, "13UL" is stock speed.

Is this useful? Probably not because the power of microcontrollers derives from their functionalities and not (much) from their speed.

Schematics

16u2 Pin Map
Due eeprom mod with header 2 zwb3ndskw8
Mod Map Top
Sopra qf31somrli
Mod Map Bottom
Retro w03zuth6lu
V2 track routes
Beware that copper "lands" are not shown, even if they are little, believe it or not it's a 3 layers PCB, as far as i know only the 3.3V net belongs to the inner layer
Vecchia con vias 7tfpuch8ej
V3 track routes
Copper "lands" are not shown, i think it's just a 2 layers PCB
Nuova con vias q5eg1abywh
ATMega16u2 stuff and library
This contains...
* The new firmware to upload on the 16u2 in "raw binary" format
* The DueEEPROM library for the IDE
* (optional) Source code to compile the 16u2 firmware with the LUFA toolchain
dueeeprom_rY9ldjEW0M.zip

Code

Untitled fileC/C++
#define SYS_BOARD_PLLAR (CKGR_PLLAR_ONE | CKGR_PLLAR_MULA(18UL) | CKGR_PLLAR_PLLACOUNT(0x3fUL) | CKGR_PLLAR_DIVA(1UL))
#define SYS_BOARD_MCKR ( PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
//Set FWS according to SYS_BOARD_MCKR configuration
EFC0->EEFC_FMR = EEFC_FMR_FWS(4); //4 waitstate flash access
EFC1->EEFC_FMR = EEFC_FMR_FWS(4);
// Initialize PLLA to 114MHz
PMC->CKGR_PLLAR = SYS_BOARD_PLLAR;
while (!(PMC->PMC_SR & PMC_SR_LOCKA)) {}
PMC->PMC_MCKR = SYS_BOARD_MCKR;
while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {}
// Re-initialize some stuff with the new speed
SystemCoreClockUpdate();

Comments

Similar projects you might like

Plant Communicator

Project tutorial by Arduino

  • 678 views
  • 0 comments
  • 4 respects

The Nerd

Project tutorial by Arduino

  • 207 views
  • 1 comment
  • 1 respect

LED Matrix Display Badge

Project tutorial by FabLabAQ

  • 636 views
  • 0 comments
  • 3 respects

PICASO 4.0 The Infinite X- Axis CNC Wall Engraver

Project tutorial by Arnab Kumar Das

  • 148 views
  • 1 comment
  • 2 respects

Object Tracker and Updater

by Rupin Chheda

  • 213 views
  • 1 comment
  • 2 respects

Temperature Control

Project tutorial by reteprelleum

  • 1,287 views
  • 1 comment
  • 9 respects
Add projectSign up / Login