On 2012-01-07, David Brown <david.br...@hesbynett.no> wrote: > On 06/01/12 20:30, Grant Edwards wrote: >> On 2012-01-06, steve ayer<a...@handhelds.org> wrote: >> >>> of course, you could put a wire on an unused gpio pin and put the >>> device on a scope; that will give you accurate timing of code >>> segments. >> >> In my experience that's usually the easiest method by far... >> > > One thing to watch out for here is that when you write something like: > > ... > setPinHi(); > test code ... > setPinLo(); > ... > > you might not be timing all of the test code, or only the test code. > The compiler can often move the code around the "setPin" statements, > especially if they are macros or functions that the compiler can see > during the compilation.
True. When measuring timings like that it's always a good idea to have a peek at the assembly to make sure you're measuring what you think you're measuring. When working with the 3.x msp430 compiler, I never saw it move any code from inside a set-pin/clear-pin pair to outside, but it's certainly allowed in many circumstances. You can try to convice the compiler not to do so by inserting memory barriers or moving "test code" into a function and calling it, but I've never had to. It's quite possible that the 4.x compiler is more aggressive about moving stuff around. When working on low level stuff like an MSP430, I pretty much always have my Makefiles set up to generate mixed C/assmebly language listings so that it's easy to keep an eye on what the compiler is doing. One advantage of that is that you quickly learn what C constructs are handled efficiently by the compiler wand what aren't -- you learn that the smallest, fastest way to do things in C on an MSP430 is not the same as on an AVR. -- Grant ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users