Arduino DUE underclock

hi guys, i'm working with some eeproms and flash parallel memories with my arduino DUE, i started this project with the UNO and now i'm porting it to DUE, hoping to gain speed due to the better clock speed and more pin availability.. now.. it seems to work just fine, but with some memories and, sometimes flashing some files, i can notice some bug or writing error.
i think this is caused by the arduino speed compared to memory access time..
is there a way to underclock or slown down arduino a LITTLE BIT? (i know delay delaymicrosecond... ) i'd really like something like delayNanoseconds, we are working with powerfull processors and in this cases a few nanoseconds make the difference!
i also thought to use the internal 32mhz oscillator for testing... is this possible? how can i do this? thank you!

i'd really like something like delayNanoseconds, we are working with powerfull processors and in this cases a few nanoseconds make the differents!

I've seen posted at time when there is a need for a shortest possible 'delay' in a AVR sketch to just insert a assembly language NOP statement which gives you a 62.5 nsec delay for each NOP on a standard arduino board. I would assume something similar could be done in a Due sketch.

Lefty

retrolefty:

i'd really like something like delayNanoseconds, we are working with powerfull processors and in this cases a few nanoseconds make the differents!

I've seen posted at time when there is a need for a shortest possible 'delay' in a AVR sketch to just insert a assembly language NOP statement which gives you a 62.5 nsec delay for each NOP on a standard arduino board. I would assume something similar could be done in a Due sketch.

Lefty

first of all thanks,
i think that in the UNO case, 16mhz, the NOP you said skip a clock cycle (1/16m)= 62.5nsecods, so yes... i'm looking for something like that
unfortunately i'm not good in arm or avr assembly.. waiting for a genius :slight_smile:

asm volatile ("nop \n\t ");  // a NOP

asm volatile (".rept 10\n\t nop \n\t .endr\n\t"); // 10 NOPs - you can change the 10 for anything reasonably small

#define MNOP(x) asm volatile (" .rept " #x "\n\t nop \n\t .endr \n\t")    // A macro I use a lot 
MNOP(20); // 20 NOPs

These work on both AVR and ARM.

:smiley: thanks!!