I took a quick look at Paul's FastOut scenario with both builds 39 and 76. It appears to be a codegen issue and not directly related to the SDK code itself.
This is what the while(1) loop looks like with the latest online compiler setup. The BL instructions are the calls to the write() method in the FastOut class. Not the fastest of code.
00001B2E 2101 MOVS R1, #1 ; 1 == 0x1
00001B30 4807 LDR R0, .+32 ; .+32 == 0x1B50
00001B32 F000 FBA5 BL.W .+1870 ; .+1870 == 0x2280
00001B36 2100 MOVS R1, #0 ; 0 == 0x0
00001B38 4805 LDR R0, .+24 ; .+24 == 0x1B50
00001B3A F000 FBA1 BL.W .+1862 ; .+1862 == 0x2280
00001B3E E7F6 B .-16 ; .-16 == 0x1B2E
Compare that to the code generated for the same loop when you revert to revision 39. Everything was inlined back then:
000021AE 4807 LDR R0, .+30 ; .+30 == 0x21CC
000021B0 F44F 2180 MOV.W R1, #0x00040000
000021B4 6381 STR R1, [R0, #56] ; 56 == 0x38
000021B6 63C1 STR R1, [R0, #60] ; 60 == 0x3C
000021B8 E7FC B .-4 ; .-4 == 0x21B4
000021CC DW $2009C000
Obviously the latest online build setup isn't as aggressive with inlining of short methods. I don't know if the compiler version was changed with revision 40 or maybe just some compiler flags. Maybe there are some flags that the mbed team can tweak to make the compiler more aggressive about inlining again. I did try adding the inline keyword to the FastOut methods but I still didn't get the desired inlining with the current compiler setup.
I hope that helps,
Adam
There seems to be a problem with the mbed LPC1768 library that slows down writing to the GPIO ports. Both DigitalOut and FastOut (which uses the FIO registers) are affected.
Back in June 2011 I wrote a simple test program, the gist of which is below.
On an LPC1768 running at 96MHz and with library version 26, this code produces a 24MHz waveform. In other words, the loop takes 4 clocks. This is as expected. With the current version of the library (76), the same code produces a 3.4MHz waveform. This equates to a 28 clock loop, i.e. 7 times slower!
Erik Olieman has independently confirmed this. Erik also reports that DigitalOut is more than 3 times slower with the current library than with the earlier one. Erik has done some digging and believes that the problem was introduced with library version 40.
Can I request that you fix this problem ASAP?
@mbed team: look at the programs FastOut and newFastOut in my repository. I can email you 'scope screen dumps if you wish.