I have code for a recursive low pass filter which is working OK but I need to increase its speed. The line which is taking too long is the following:
filt1 = filt1 - ( filt1 >> 4 ) + ad_ref;
In this, filt1 and ad_ref are 32bit unsigned integers. A long shot, but I was wondering if anyone can suggest a way of getting this simple code to go faster. At the moment I am running the PIC at 40MHz and the line executes in a little under 5us.
Thanks
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
Posted: Sat Sep 11, 2010 11:32 am
I count exactly 46 instruction cycles (4.6 us). int32 arithmetic is quite bulky with PIC18, I don't see an option to speed it up. Switching to assembly coding can't save more than a few register load operations. If you don't need actually 32 bit, there would be room for timing optimizations.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum