I've been experimenting with various LM4F120 peripherals. While doing this I was not being careful about consistently using ROM_* calls. I created a simple delay function using SysCtlDelay() but while testing a timer utility I found a problem with my timing results. After a lot of wasted time I finally discovered that for me the SysCtlDelay() was not producing an accurate delay. I eventually tried changing the call to ROM_SysCtlDelay() and then began getting the results I expected.
I'm not sure if this is a known problem or not but here's the code I used to test it:
My delay function:
void delayMS(int ms) {
//ROM_SysCtlDelay( (ROM_SysCtlClockGet()/(3*1000))*ms ) ; // more accurate
SysCtlDelay( (SysCtlClockGet()/(3*1000))*ms ) ; // less accurate
}
....
a = getTimeStamp() ; // returns double derived from Hibernate RTC
onLED(BLUE) ; // simply turns on BLUE LED
delayMS(15) ; // calls for 15ms delay
offLED(BLUE) ; // turns off BLUE LED
b = getTimeStamp() ; // gets another measure of time
diff = b - a ; // estimates delay time (w/in a few hundred uS
doubleToStringL("diff=", diff, true) ; // label, double, true=finish w \n
.... Note: above code executed in 2 second loop
I measured the delay two ways. I used a logic analyzer to monitor BLUE LED pin on Stellaris Launchpad and by comparing RTC time before and after delay.
Both logic analyzer and timestamp differences were within 10uS of each other so I believe I was measuring relatively accurately.
With ROM_SysCtlDelay(), I got the delay I expected within a few hundred uS as measure by logic analyzer and timestamp difference.
With SysCtlDelay() I did not get the delays I expected. Here's a sample
Delay amount Measured
in MS delay
2000 2222.2
1500 1666.6
1000 1111.1
900 999.9
800 888.8
700 777.77
500 555.5
400 444.4
300 333.3
200 400.3
100 200.0
50 100.0
25 50.0
15 30.3
5 10.0
1 2.0
The patterns are suspicious to say the least.
In any case, I'm moving on now that I'm getting better results with ROM_SysCtlDelay(). It would be nice to get some feedback if anything is known about this problem.
Thanks
Target LM4F120, CCS 5.2, host Ubuntu 12.4, shoe size 11.5