Arduino DUE @ 84MHz

does anyone know how to get the adruino due operating at the maximum 84MHz core clock frequency?
I am programming in the atmel studio IDE 6. I created a very simple test application that is running on a PLLA of 192MHz which is divided by 8 to get 24MHz core clock. But if I select the /4 prescaler for the master clock nothing works anymore.

#include <asf.h>

int main (void)
{
/* Insert system clock initialization code here (sysclk_init()). */
pmc_enable_pllack(47,10,1); //192MHz
pmc_switch_mck_to_pllack(PMC_MCKR_PRES_CLK_8);// core clock 24MHz

board_init();

PIOA->PIO_PER = PIO_PER_P11;
PIOA->PIO_OER = PIO_OER_P11;

while (1)
{
PIOA->PIO_SODR = PIO_SODR_P11;
for(uint32_t i=0;i<1000000;i++);
PIOA->PIO_CODR = PIO_CODR_P11;
for(uint32_t i=0;i<1000000;i++);
}

/* Insert application code here, after the board has been initialized. */
}

The Arduino environment doesn't let you change clock frequency, not without a lot of hoops to jump through. It runs at 84MHz always. Have a look at the code that the Arduino IDE generates for main() and you might find a clue.

MorganS:
The Arduino environment doesn't let you change clock frequency, not without a lot of hoops to jump through. It runs at 84MHz always. Have a look at the code that the Arduino IDE generates for main() and you might find a clue.

Thanks for you reply, but I am not using the arduino IDE and I can change the clock speed as you can see in the code I posted. However I can't get it to operate at 84MHz (or something above 24MHz).

I finally found the reason why it didn’t work above 24MHz.
I found another topic about “overclocking” the due where the user configured the flash wait register.
Digging through the datasheet I found the table specifying the flash wait configuration vs. core speed.
I had to increase this to 4 to get the due to work at 84MHz.

#include <asf.h>

int main (void)
{
/* Insert system clock initialization code here (sysclk_init()). */
pmc_enable_pllack(41,10,1); //168MHz

EFC0->EEFC_FMR = EEFC_FMR_FWS(4);
EFC1->EEFC_FMR = EEFC_FMR_FWS(4);

pmc_switch_mck_to_pllack(PMC_MCKR_PRES_CLK_2);// core clock 84MHz

board_init();

PIOA->PIO_PER = PIO_PER_P11;
PIOA->PIO_OER = PIO_OER_P11;

while (1)
{
PIOA->PIO_SODR = PIO_SODR_P11;
for(uint32_t i=0;i<1000000;i++);
PIOA->PIO_CODR = PIO_CODR_P11;
for(uint32_t i=0;i<1000000;i++);
}

/* Insert application code here, after the board has been initialized. */
}