I'm using a Tiva C series launchpad (TM4C123G) to sample analog data using an external ADC (ADC0804). The ADC is clocked at 1.4MHz. The SysCtlClockSet command was used to set clock freq to 80MHz.
A square wave is being generated on a pin, with a frequency same as the sampling rate, using the code given below. So this gives us the sampling rate on an oscilloscope.
For some reason the sampling rate is TOO low. It is only ~330KHz with NO command in the loop. It drops to about ~280KHz with one digitalRead and to just a few hundred Hz with a SerialPrintln().
What is causing it to run so slow