TIMER16 Prescale Error

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by jagweb on Sat Mar 31 06:12:54 MST 2012
This is my first post so please be gentle.  I have been working with the 16 bit timers using the LPC1114 and the driver library provided in version 4.2.0 Build 264.  My timing was off by around 2% and was having some difficulty finding the root cause.  I searched way too long to find out it was an off by one error.  The problem is with the MHZ_PRESCALE define in the timer16.h driver code.  When you set the prescaler to 48 you are actually dividing by 49 because the prescaler by design is off by 1.   so the define should be (TIMER _CLOCKFREQ/1000000-1).  I really hope this helps someone else. It would be nice to see this fix incorporated on the next version or build. 

In general, I think the LPCXpresso is a great tool :) and appreciate free tools for evalution and small projects.  The example projects are nice and get you running very fast.  My general impression of the M0 parts is they are simple to use (this is not always the case with other vendors).  Keep up the good work.