I have a very simple C program that toggles a pin on a Cortex-M3 board (SAM3X8E) with a 84MHz clock speed. I built this using Atmel Studio 6.1.
#include <asf.h>
int main (void)
{
board_init();
PIOB->PIO_PER = PIO_PB27; //Enable PIO
PIOB->PIO_OER = PIO_PB27; //Set to OUTPUT
PIOB->PIO_PUDR = PIO_PB27; //Disable the pull up resistor
while(1) {
PIOB->PIO_SODR = PIO_PB27; //Enable output
PIOB->PIO_CODR = PIO_PB27; //Disable output
}
}
Now when I load this onto the board, and hook up an oscilloscope up to the pin, I see the signal pulsating at about 700kHz. I would have thought that the speed of the cycle would have been much quicker with this minimalistic code.
Is it possible to get a GPIO frequency higher than a MHz using this setup? Is it my build environment that is not producing optimal code? Is it possible to get faster GPIO using another technique?