Part Number: EK-TM4C1294XL
Tool/software: Code Composer Studio
A new project has shown up.
We want to read in a (long) string of 32 data words from our equipment and send it onto ethernet.
Just for testing the GPIO speed, I created a small program, that read 32 bits in from ports A, K, M (8 bit each), C and D (4 bit each), stitch it all together in a single uint32, and then back.
I added a toggle output so I could measure loop time with an oscilloscope.
It turns out one tour through the loop takes 1.3 us. If I comment out reading the 32 bits (assigning values to a-e instead of reading in from ports) , the loop takes 300 ns.
In other words, one port access takes 200 ns, while everything else in the loop takes 100.
In this project, however, I need at least a factor 3 up in my data rate!
Are the used macros simply too slow? (alternatives?)
Or is the processor, running at 120 MHz, not faster than that?
uint32_t Get32(void)
{
int a,b,c,d,e;
uint32_t res;
a=GPIOPinRead(GPIO_PORTA_BASE,0xFF); //Read port A
b=GPIOPinRead(GPIO_PORTK_BASE,0xFF); //Read port K
c=GPIOPinRead(GPIO_PORTM_BASE,0xFF); //Read port M
d=GPIOPinRead(GPIO_PORTD_BASE,0x0F); //Read port D
e=GPIOPinRead(GPIO_PORTC_BASE,0xF0); //Read port C
res = a + b<<8 + c<<16 + d<<24 + e<<28;
return res;
}
void main(void)
{
int Indicator;
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
Setup();
//
// Loop forever.
//
Indicator=0;
while (1) {
Get32();
if (Indicator==0)
Indicator=4;
else
Indicator=0;
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_2,Indicator);
}
}