<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-16318</id>
	<title>Nabble - PIC - [AVR]</title>
	<updated>2009-09-10T06:38:00Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/PIC----AVR--f16318.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/PIC----AVR--f16318.html" />
	<subtitle type="html">Items specific to the Atmel AVR microcontrollers.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-25383621</id>
	<title>Start-up / Wake-up / Reset timings on ATTiny13A</title>
	<published>2009-09-10T06:38:00Z</published>
	<updated>2009-09-10T06:38:00Z</updated>
	<author>
		<name>Tamas Rudnai</name>
	</author>
	<content type="html">Hello,
&lt;br&gt;&lt;br&gt;I have hard times to understand what the datasheet is trying to interpret in
&lt;br&gt;timings for reset from different state of the AVR ATTiny13A.
&lt;br&gt;&lt;br&gt;Particularly I am interested when the internal RC oscillator is used for
&lt;br&gt;clocking the chip. As I understood I can set up different delay when comes
&lt;br&gt;up from powered down mode. It ads additional 14 CK to the 6 CK normal
&lt;br&gt;start-up time + can set further 4ms or 64ms.
&lt;br&gt;&lt;br&gt;What is not clear when is this delay added to the normal start-up time? Only
&lt;br&gt;at POR, or also when waking up from power down sleep mode? Also could not
&lt;br&gt;figure out from the datasheet the timing of waking up the MCU from idle
&lt;br&gt;mode?
&lt;br&gt;&lt;br&gt;In addition to this grey cloud I could not find information of this 6 CK
&lt;br&gt;startup time? I guess ones the oscillator is up and stable then it counts to
&lt;br&gt;6 and this is this this 6 CK startup time, but how long does it take to the
&lt;br&gt;oscillator circuit to be started up into a stable condition when this 6 CK
&lt;br&gt;starts counting? Especially regarding this to different thermal and power
&lt;br&gt;supply conditions?
&lt;br&gt;&lt;br&gt;If you could point me to a link or which documentation shall I read on this
&lt;br&gt;subject, it would be much appreciated.
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;Tamas
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.mcuhobby.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mcuhobby.com&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Start-up---Wake-up---Reset-timings-on-ATTiny13A-tp25383621p25383621.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23430526</id>
	<title>problems with division</title>
	<published>2009-05-07T09:25:24Z</published>
	<updated>2009-05-07T09:25:24Z</updated>
	<author>
		<name>pgomez82</name>
	</author>
	<content type="html">I have this simple program:
&lt;br&gt;&lt;br&gt;int	fb;
&lt;br&gt;int fc;
&lt;br&gt;signed long int Rs;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (1)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fb = 400;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fc = 2;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Rs = fb/fc;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delay (20);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UDR = 0xf0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (!(UCSRA &amp; (1&amp;lt;&amp;lt;UDRE)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UDR = Rs;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (!(UCSRA &amp; (1&amp;lt;&amp;lt;UDRE)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Rs &amp;lt;&amp;lt;= 8;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UDR = Rs;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;and the port receives:
&lt;br&gt;0xf0
&lt;br&gt;240 &amp;nbsp; 136 000 	
&lt;br&gt;240 &amp;nbsp; 200 000 	
&lt;br&gt;240 &amp;nbsp; 136 000 	
&lt;br&gt;240 &amp;nbsp; 200 000 	
&lt;br&gt;240 &amp;nbsp; 200 000 	
&lt;br&gt;240 &amp;nbsp; 200 000 	
&lt;br&gt;&lt;br&gt;I don´t know why 136 appears all the time. The result should be 200. I write this program because I´m not able to understand whats happening with divisions.
&lt;br&gt;&lt;br&gt;Thank you in advance
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problems-with-division-tp23430526p23430526.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23322391</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-30T11:45:49Z</published>
	<updated>2009-04-30T11:45:49Z</updated>
	<author>
		<name>M. Adam Davis-2</name>
	</author>
	<content type="html">On Wed, Apr 29, 2009 at 7:06 PM, William &amp;quot;Chops&amp;quot; Westfield
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23322391&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Apr 29, 2009, at 7:56 AM, M. Adam Davis wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; If you decide you only need 1% accuracy, then you only need the first
&lt;br&gt;&amp;gt;&amp;gt; two factors (128, 8192), and if you want 0.001% accuracy you need 6
&lt;br&gt;&amp;gt;&amp;gt; factors (128, 8192, 16384, 262144, 2097152, 8388608).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; To get the accuracy you talk about, do you need to have &amp;quot;perfect&amp;quot;
&lt;br&gt;&amp;gt; fractions (1/128 * input) or does truncation suffice? (Rounding?)   I
&lt;br&gt;&amp;gt; think the last time I actually tried to implement one of these &amp;quot;sum of
&lt;br&gt;&amp;gt; power-of-2 fractions&amp;quot; I ended up getting really lousy results, that I
&lt;br&gt;&amp;gt; attributed (rightly or wrongly) to the bits shifted off the right
&lt;br&gt;&amp;gt; side...
&lt;/div&gt;&lt;br&gt;That's correct, this is still subject to rounding error.
&lt;br&gt;&lt;br&gt;If you want to include *all* the bits in the calculation, you reverse
&lt;br&gt;the process:
&lt;br&gt;Original right &amp;nbsp;shifts: 7, 13, 14, 18
&lt;br&gt;Reverse left shifts: 11, 5, 4, 0 then shift right by 18
&lt;br&gt;&lt;br&gt;This takes a &amp;nbsp;maximum of 2x the number of bits in the original - in
&lt;br&gt;other words, it could take up to 48+48 bits to process a 48 bit
&lt;br&gt;number, if you wanted to get as much accuracy as possible.
&lt;br&gt;&lt;br&gt;output = (input &amp;lt;&amp;lt; 11 + input &amp;lt;&amp;lt; 5 + input &amp;lt;&amp;lt; 4 + input) &amp;gt;&amp;gt; 18;
&lt;br&gt;&lt;br&gt;I don't know if the code generator mentioned actually computes the
&lt;br&gt;accuracy based on all the rounding errors, or just the error from the
&lt;br&gt;&amp;quot;ideal&amp;quot; equation where the intermediate values are computed using
&lt;br&gt;floating point (ie, takes all bits into account). &amp;nbsp;But it must not,
&lt;br&gt;because the rounding errors can be truly nasty:
&lt;br&gt;&lt;br&gt;Take 12500/125, for instance. &amp;nbsp;The ideal result is 100. &amp;nbsp;The binary
&lt;br&gt;division approximate, using floating point rather than integers, is
&lt;br&gt;99.99275. Using all the bits (as in the left shift then right shift
&lt;br&gt;above) you get 99 - which is the integer equivalent of the floating
&lt;br&gt;point version of the binary division.
&lt;br&gt;&lt;br&gt;This is 1% off.
&lt;br&gt;&lt;br&gt;The left shift version, however, results in 98, with 4 factors (128,
&lt;br&gt;8192, 16384, 262144). &amp;nbsp;The right shift version, by preserving all the
&lt;br&gt;bits, gets at least as close as one digit (and that can be improved by
&lt;br&gt;rounding - look at the 18'th bit before it's shifted off and add 1 to
&lt;br&gt;the result if it's high). &amp;nbsp;The original right shift version can be off
&lt;br&gt;by more than one integer. &amp;nbsp;One integer may be a lot or a little,
&lt;br&gt;depending on your range and usage.
&lt;br&gt;&lt;br&gt;If you use this repeatedly, as in infinite impules response filters,
&lt;br&gt;you're going to have bad problems.
&lt;br&gt;&lt;br&gt;Ideally you'd use all the factors down to the 48th bit:
&lt;br&gt;7, 13, 14, 18, 21, 24, 25, 27, 28, 29, 31, 34, 36, 37, 38, 39, 43, 44,
&lt;br&gt;46 (left shifts)
&lt;br&gt;&lt;br&gt;But even then, you're using integer intemediate values, so you'd still
&lt;br&gt;have rounding errors, just not as significant.
&lt;br&gt;&lt;br&gt;However, it's still faster than 'real' division, and yields good
&lt;br&gt;results for most cases.
&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23322391.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23311636</id>
	<title>RE: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-30T00:43:41Z</published>
	<updated>2009-04-30T00:43:41Z</updated>
	<author>
		<name>Michael Rigby-Jones-2</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23311636&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;piclist-bounces@...&lt;/a&gt; [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23311636&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;piclist-bounces@...&lt;/a&gt;] On
&lt;br&gt;Behalf
&lt;br&gt;&amp;gt; Of Tamas Rudnai
&lt;br&gt;&amp;gt; Sent: 29 April 2009 19:03
&lt;br&gt;&amp;gt; To: Microcontroller discussion list - Public.
&lt;br&gt;&amp;gt; Subject: Re: [AVR] divide 48bit number by (constant) 125 ?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; That's a very nice explanation. &amp;nbsp;Exactly these kind of things what a
&lt;br&gt;high
&lt;br&gt;&amp;gt; level language compiler supposed to do, however. It is actually really
&lt;br&gt;sad
&lt;br&gt;&amp;gt; if avr-gcc does not support microcontroller specific optimizations and
&lt;br&gt;&amp;gt; storage classes.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;It does as much as possible, but it can't arbitrarily convert integer
&lt;br&gt;multiplies/divides to shifts and adds unless the multiplier/divider can
&lt;br&gt;be perfectly expressed in a small, finite number of terms. &amp;nbsp;If not there
&lt;br&gt;will always be some accuracy trade-off against the number of terms used.
&lt;br&gt;&lt;br&gt;Also there is often a danger of impaired accuracy when the operands
&lt;br&gt;magnitudes are small, e.g. in this case an input of 126, 126 or 127 will
&lt;br&gt;give a valid result of 1 when using an integer division. &amp;nbsp;When using
&lt;br&gt;shifts and additions, the result will be (incorrectly) zero for these
&lt;br&gt;inputs. &amp;nbsp;This may well be acceptable, but how would a compiler know
&lt;br&gt;this?
&lt;br&gt;&lt;br&gt;IMO this is exactly the kind of optimisation is where human intervention
&lt;br&gt;should be required since the compiler doesn't have enough information to
&lt;br&gt;make a valid decision.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;Mike
&lt;br&gt;&lt;br&gt;=======================================================================
&lt;br&gt;This e-mail is intended for the person it is addressed to only. The
&lt;br&gt;information contained in it may be confidential and/or protected by
&lt;br&gt;law. If you are not the intended recipient of this message, you must
&lt;br&gt;not make any use of this information, or copy or show it to any
&lt;br&gt;person. Please contact us immediately to tell us that you have
&lt;br&gt;received this e-mail, and return the original to us. Any use,
&lt;br&gt;forwarding, printing or copying of this message is strictly prohibited.
&lt;br&gt;No part of this message can be considered a request for goods or
&lt;br&gt;services.
&lt;br&gt;=======================================================================
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23311636.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23307413</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T16:06:11Z</published>
	<updated>2009-04-29T16:06:11Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">&lt;br&gt;On Apr 29, 2009, at 7:56 AM, M. Adam Davis wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; If you decide you only need 1% accuracy, then you only need the first
&lt;br&gt;&amp;gt; two factors (128, 8192), and if you want 0.001% accuracy you need 6
&lt;br&gt;&amp;gt; factors (128, 8192, 16384, 262144, 2097152, 8388608).
&lt;br&gt;&lt;br&gt;To get the accuracy you talk about, do you need to have &amp;quot;perfect&amp;quot; &amp;nbsp;
&lt;br&gt;fractions (1/128 * input) or does truncation suffice? (Rounding?) &amp;nbsp; I &amp;nbsp;
&lt;br&gt;think the last time I actually tried to implement one of these &amp;quot;sum of &amp;nbsp;
&lt;br&gt;power-of-2 fractions&amp;quot; I ended up getting really lousy results, that I &amp;nbsp;
&lt;br&gt;attributed (rightly or wrongly) to the bits shifted off the right &amp;nbsp;
&lt;br&gt;side...
&lt;br&gt;&lt;br&gt;BillW
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23307413.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23306596</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T15:07:14Z</published>
	<updated>2009-04-29T15:07:14Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">&lt;br&gt;On Apr 29, 2009, at 7:56 AM, M. Adam Davis wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Slightly faster (since a one bit shift takes a full instruction &amp;nbsp;
&lt;br&gt;&amp;gt; cycle):
&lt;br&gt;&amp;gt; temp = input;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 7;
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 6; // temp = input &amp;gt;&amp;gt; 13
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 1; &amp;nbsp;// temp = input &amp;gt;&amp;gt; 14
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 4; // temp = input &amp;gt;&amp;gt; 18
&lt;br&gt;&amp;gt; result += temp;
&lt;/div&gt;&lt;br&gt;This is especially interesting, because after all the original &amp;quot;ticks&amp;quot; &amp;nbsp;
&lt;br&gt;input BEFORE the multiply is already &amp;quot;input&amp;gt;&amp;gt;7&amp;quot; &amp;nbsp;(it becomes a &amp;nbsp;
&lt;br&gt;multiply by &amp;quot;128/125&amp;quot;, which is just fine...)
&lt;br&gt;&lt;br&gt;BillW
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23306596.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23305212</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T13:34:01Z</published>
	<updated>2009-04-29T13:34:01Z</updated>
	<author>
		<name>Bob Ammerman</name>
	</author>
	<content type="html">&lt;br&gt;----- Original Message ----- 
&lt;br&gt;From: &amp;quot;Dave Tweed&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23305212&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pic@...&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23305212&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;piclist@...&lt;/a&gt;&amp;gt;
&lt;br&gt;Sent: Wednesday, April 29, 2009 7:19 AM
&lt;br&gt;Subject: Re: [AVR] divide 48bit number by (constant) 125 ?
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; William &amp;quot;Chops&amp;quot; Westfield wrote:
&lt;br&gt;&amp;gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt;&amp;gt; maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt;&amp;gt; least a 48bit intermediate value.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Do you have access to the ISR? I would be inclined to do the following,
&lt;br&gt;&amp;gt; rather than (or in addition to) simply counting the raw ticks:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;/* microseconds can be a 16-bit integer */
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;microseconds += microsecondsPerTick;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;while (microseconds &amp;gt;= 1000) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;microseconds -= 1000;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;++milliseconds;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- Dave Tweed
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;/div&gt;&lt;br&gt;You can use a trick similar to a binary to decimal
&lt;br&gt;conversion algorithm to convert your value.
&lt;br&gt;&lt;br&gt;A short description of the algorithm:
&lt;br&gt;&lt;br&gt;1: compute ticks * microseconds per tick
&lt;br&gt;2: convert to a mixed radix representation where the low-order 3 (decimal) 
&lt;br&gt;digits of the number are kept in a separate variable from the rest of the 
&lt;br&gt;number.
&lt;br&gt;3: toss out the low-order 3 digits, keeping the number containing the rest 
&lt;br&gt;of the value.
&lt;br&gt;&lt;br&gt;A longer description in pseudo-C
&lt;br&gt;&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;in_hi;
&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;in_mid;
&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;in_low;
&lt;br&gt;&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;out_hi
&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;out_mid
&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;out_low
&lt;br&gt;uint16 &amp;nbsp; &amp;nbsp;out_toss;
&lt;br&gt;&lt;br&gt;out_hi = out_mid = out_low = out_toss = 0;
&lt;br&gt;for (i=0; i &amp;lt; 48; ++i)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// double the output value, taking
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// ...into account its mixed radix
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// ...representation
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;out_toss &amp;lt;&amp;lt;= 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;carry = 0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (out_toss &amp;gt; 1000)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out_toss -= 1000;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; carry = 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;shift [out_hi:out_mid:out_low] left one bit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;shifting 'carry' into lsbit
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// add in the next bit of the input value
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// to the accumulated value. this is
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// simplified by the fact that we know
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the low-order bit is a zero (after
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the doubling above)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;shift [in_hi:in_mid:in_low] left one bit;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (the bit shifted out is 1)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;out_toss |= 1;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;// the resulting millisecond count is in
&lt;br&gt;// [out_hi:out_mid:out_low]
&lt;br&gt;&lt;br&gt;This could be very efficiently implemented in PIC assembly code, and I 
&lt;br&gt;imagine it wouldn't be too much different for an AVR. It is a little ugly in 
&lt;br&gt;true C because of the multiword shifts.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23305212.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23302692</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T11:02:50Z</published>
	<updated>2009-04-29T11:02:50Z</updated>
	<author>
		<name>Tamas Rudnai</name>
	</author>
	<content type="html">That's a very nice explanation. &amp;nbsp;Exactly these kind of things what a high
&lt;br&gt;level language compiler supposed to do, however. It is actually really sad
&lt;br&gt;if avr-gcc does not support microcontroller specific optimizations and
&lt;br&gt;storage classes.
&lt;br&gt;&lt;br&gt;Tamas
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Wed, Apr 29, 2009 at 3:56 PM, M. Adam Davis &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23302692&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;stienman@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Just in case the below wasn't explicit enough, the info below would be
&lt;br&gt;&amp;gt; converted into C as follows:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; result = input / 125; &amp;nbsp;// Original
&lt;br&gt;&amp;gt; result = input / 128 + input / 8192 + input / 16384 + input / 262144;
&lt;br&gt;&amp;gt; // To binary equivalant ( with 0.007% error)
&lt;br&gt;&amp;gt; result = input &amp;gt;&amp;gt; 7 + input &amp;gt;&amp;gt; 13 + input &amp;gt;&amp;gt; 14 + input &amp;gt;&amp;gt; 18; //
&lt;br&gt;&amp;gt; Using shifts rather than division (faster, same result)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Slightly faster (since a one bit shift takes a full instruction cycle):
&lt;br&gt;&amp;gt; temp = input;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 7;
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 6; // temp = input &amp;gt;&amp;gt; 13
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 1; &amp;nbsp;// temp = input &amp;gt;&amp;gt; 14
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt; temp = temp &amp;gt;&amp;gt; 4; // temp = input &amp;gt;&amp;gt; 18
&lt;br&gt;&amp;gt; result += temp;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This can be optimized further, but it only requires a total of 18
&lt;br&gt;&amp;gt; shifts (whereas the previous version might have actually generated 52
&lt;br&gt;&amp;gt; shifts) and a similar number of additions. &amp;nbsp;Across a 48 bit number on
&lt;br&gt;&amp;gt; an 8 bit processor this adds up...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If you decide you only need 1% accuracy, then you only need the first
&lt;br&gt;&amp;gt; two factors (128, 8192), and if you want 0.001% accuracy you need 6
&lt;br&gt;&amp;gt; factors (128, 8192, 16384, 262144, 2097152, 8388608).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -Adam
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Wed, Apr 29, 2009 at 10:38 AM, M. Adam Davis &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23302692&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;stienman@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt; This should give you what you need - you can turn a division into a
&lt;br&gt;&amp;gt; &amp;gt; sum of several binary divisions:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://piclist.com/techref/method/math/divconst.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://piclist.com/techref/method/math/divconst.htm&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; There is an online code generator here, though it only goes up to 32
&lt;br&gt;&amp;gt; &amp;gt; bits, but you probably don't care about the code generated, just the
&lt;br&gt;&amp;gt; &amp;gt; binary division factors:
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; 1/125 = 0.008, which happens to be very close to:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; ; ALGORITHM:
&lt;br&gt;&amp;gt; &amp;gt; ; Clear accumulator
&lt;br&gt;&amp;gt; &amp;gt; ; Add input / 128 to accumulator
&lt;br&gt;&amp;gt; &amp;gt; ; Add input / 8192 to accumulator
&lt;br&gt;&amp;gt; &amp;gt; ; Add input / 16384 to accumulator
&lt;br&gt;&amp;gt; &amp;gt; ; Add input / 262144 to accumulator
&lt;br&gt;&amp;gt; &amp;gt; ; Move accumulator to result
&lt;br&gt;&amp;gt; &amp;gt; ;
&lt;br&gt;&amp;gt; &amp;gt; ; Approximated constant: 0.00799942, Error: 0.00724792 %
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; You can change the &amp;quot;ConstErr=0.05&amp;quot; to a finer value to reduce the error
&lt;br&gt;&amp;gt; further.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; -Adam
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; On Wed, Apr 29, 2009 at 3:14 AM, William &amp;quot;Chops&amp;quot; Westfield
&lt;br&gt;&amp;gt; &amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23302692&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; least a 48bit intermediate value.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; It would be nice if the code were in C. &amp;nbsp;Avr gcc, in particular.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; There are 8, 16, 32, and even 64 bit math functions available, but of
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; course they're *C*, so they don't let you actually do mixed-sized
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; math, nor are they likely to optimized
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; The code is not particularly time critical, but it would be nice if it
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; were as small and fast as possible (using 64bit long longs seems
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; excessive.)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thoughts? &amp;nbsp;Any pointers to mixed-size C math functions in general? &amp;nbsp;In
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; principle, I think I understand how to do this, but ... &amp;nbsp;Is there a
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; way to take advantage of the constant? &amp;nbsp;Of 125 in particular? &amp;nbsp;(lots
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of one bits there...)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Bill W
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.mcuhobby.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mcuhobby.com&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23302692.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23302130</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T10:35:07Z</published>
	<updated>2009-04-29T10:35:07Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">&lt;br&gt;On Apr 29, 2009, at 4:19 AM, Dave Tweed wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Do you have access to the ISR? I would be inclined to do the &amp;nbsp;
&lt;br&gt;&amp;gt; following,
&lt;br&gt;&amp;gt; rather than (or in addition to) simply counting the raw ticks:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;/* microseconds can be a 16-bit integer */
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;microseconds += microsecondsPerTick;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;while (microseconds &amp;gt;= 1000) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;microseconds -= 1000;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;++milliseconds;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;/div&gt;&lt;br&gt;This is in fact the currently proposed solution (plus or minus &amp;nbsp;
&lt;br&gt;optimization), although some would rather the ISR were shorter.
&lt;br&gt;&lt;br&gt;(avr-gcc will &amp;quot;optimize&amp;quot; that while loop to a divide, BTW. &amp;nbsp;ouch! (and &amp;nbsp;
&lt;br&gt;Grr!)
&lt;br&gt;&lt;a href=&quot;http://www.avrfreaks.net/index.php&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.avrfreaks.net/index.php&lt;/a&gt;? 
&lt;br&gt;name=PNphpBB2&amp;file=viewtopic&amp;t=78209 )
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23302130.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23299950</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T08:32:23Z</published>
	<updated>2009-04-29T08:32:23Z</updated>
	<author>
		<name>Tony Vandiver-2</name>
	</author>
	<content type="html">why not find out where ticks is incremented, and add another variable 
&lt;br&gt;that increments every 1K times ticks gets incremented, and use that 
&lt;br&gt;instead of ticks? &amp;nbsp;Or depending on the accuracy you want, change the 
&lt;br&gt;formula to msecs = (ticks&amp;gt;&amp;gt;17)*&amp;lt;microsecondsPerTick&amp;gt;*131;
&lt;br&gt;&lt;br&gt;Tony
&lt;br&gt;&lt;br&gt;Marechiare wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; to return the number of milliseconds elapsed based on a
&lt;br&gt;&amp;gt;&amp;gt; count maintained by a timer ISR. &amp;nbsp;microsecondsPerTick
&lt;br&gt;&amp;gt;&amp;gt; is a nice constant number like 1024 or 2048, so the
&lt;br&gt;&amp;gt;&amp;gt; multiplication becomes a shift
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So, what you need is just to divide by 1000 after the shifting.
&lt;br&gt;&amp;gt; Why not convert it to decimal, discard last 3 digits, and then convert
&lt;br&gt;&amp;gt; it back to binary?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; The code is not particularly time critical
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23299950.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23299365</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T08:06:47Z</published>
	<updated>2009-04-29T08:06:47Z</updated>
	<author>
		<name>Marechiare</name>
	</author>
	<content type="html">&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;    (ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to return the number of milliseconds elapsed based on a
&lt;br&gt;&amp;gt; count maintained by a timer ISR.  microsecondsPerTick
&lt;br&gt;&amp;gt; is a nice constant number like 1024 or 2048, so the
&lt;br&gt;&amp;gt; multiplication becomes a shift
&lt;br&gt;&lt;br&gt;So, what you need is just to divide by 1000 after the shifting.
&lt;br&gt;Why not convert it to decimal, discard last 3 digits, and then convert
&lt;br&gt;it back to binary?
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; The code is not particularly time critical
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23299365.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23299283</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T07:56:10Z</published>
	<updated>2009-04-29T07:56:10Z</updated>
	<author>
		<name>M. Adam Davis-2</name>
	</author>
	<content type="html">Just in case the below wasn't explicit enough, the info below would be
&lt;br&gt;converted into C as follows:
&lt;br&gt;&lt;br&gt;result = input / 125; &amp;nbsp;// Original
&lt;br&gt;result = input / 128 + input / 8192 + input / 16384 + input / 262144;
&lt;br&gt;// To binary equivalant ( with 0.007% error)
&lt;br&gt;result = input &amp;gt;&amp;gt; 7 + input &amp;gt;&amp;gt; 13 + input &amp;gt;&amp;gt; 14 + input &amp;gt;&amp;gt; 18; //
&lt;br&gt;Using shifts rather than division (faster, same result)
&lt;br&gt;&lt;br&gt;Slightly faster (since a one bit shift takes a full instruction cycle):
&lt;br&gt;temp = input;
&lt;br&gt;temp = temp &amp;gt;&amp;gt; 7;
&lt;br&gt;result += temp;
&lt;br&gt;temp = temp &amp;gt;&amp;gt; 6; // temp = input &amp;gt;&amp;gt; 13
&lt;br&gt;result += temp;
&lt;br&gt;temp = temp &amp;gt;&amp;gt; 1; &amp;nbsp;// temp = input &amp;gt;&amp;gt; 14
&lt;br&gt;result += temp;
&lt;br&gt;temp = temp &amp;gt;&amp;gt; 4; // temp = input &amp;gt;&amp;gt; 18
&lt;br&gt;result += temp;
&lt;br&gt;&lt;br&gt;This can be optimized further, but it only requires a total of 18
&lt;br&gt;shifts (whereas the previous version might have actually generated 52
&lt;br&gt;shifts) and a similar number of additions. &amp;nbsp;Across a 48 bit number on
&lt;br&gt;an 8 bit processor this adds up...
&lt;br&gt;&lt;br&gt;If you decide you only need 1% accuracy, then you only need the first
&lt;br&gt;two factors (128, 8192), and if you want 0.001% accuracy you need 6
&lt;br&gt;factors (128, 8192, 16384, 262144, 2097152, 8388608).
&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;On Wed, Apr 29, 2009 at 10:38 AM, M. Adam Davis &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23299283&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;stienman@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; This should give you what you need - you can turn a division into a
&lt;br&gt;&amp;gt; sum of several binary divisions:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://piclist.com/techref/method/math/divconst.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://piclist.com/techref/method/math/divconst.htm&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; There is an online code generator here, though it only goes up to 32
&lt;br&gt;&amp;gt; bits, but you probably don't care about the code generated, just the
&lt;br&gt;&amp;gt; binary division factors:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1/125 = 0.008, which happens to be very close to:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ; ALGORITHM:
&lt;br&gt;&amp;gt; ; Clear accumulator
&lt;br&gt;&amp;gt; ; Add input / 128 to accumulator
&lt;br&gt;&amp;gt; ; Add input / 8192 to accumulator
&lt;br&gt;&amp;gt; ; Add input / 16384 to accumulator
&lt;br&gt;&amp;gt; ; Add input / 262144 to accumulator
&lt;br&gt;&amp;gt; ; Move accumulator to result
&lt;br&gt;&amp;gt; ;
&lt;br&gt;&amp;gt; ; Approximated constant: 0.00799942, Error: 0.00724792 %
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; You can change the &amp;quot;ConstErr=0.05&amp;quot; to a finer value to reduce the error further.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -Adam
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Wed, Apr 29, 2009 at 3:14 AM, William &amp;quot;Chops&amp;quot; Westfield
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23299283&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;    (ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt;&amp;gt; maintained by a timer ISR.  microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;    (ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt;&amp;gt; least a 48bit intermediate value.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; It would be nice if the code were in C.  Avr gcc, in particular.
&lt;br&gt;&amp;gt;&amp;gt; There are 8, 16, 32, and even 64 bit math functions available, but of
&lt;br&gt;&amp;gt;&amp;gt; course they're *C*, so they don't let you actually do mixed-sized
&lt;br&gt;&amp;gt;&amp;gt; math, nor are they likely to optimized
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The code is not particularly time critical, but it would be nice if it
&lt;br&gt;&amp;gt;&amp;gt; were as small and fast as possible (using 64bit long longs seems
&lt;br&gt;&amp;gt;&amp;gt; excessive.)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thoughts?  Any pointers to mixed-size C math functions in general?  In
&lt;br&gt;&amp;gt;&amp;gt; principle, I think I understand how to do this, but ...  Is there a
&lt;br&gt;&amp;gt;&amp;gt; way to take advantage of the constant?  Of 125 in particular?  (lots
&lt;br&gt;&amp;gt;&amp;gt; of one bits there...)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt;&amp;gt; Bill W
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23299283.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23298946</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T07:38:06Z</published>
	<updated>2009-04-29T07:38:06Z</updated>
	<author>
		<name>M. Adam Davis-2</name>
	</author>
	<content type="html">This should give you what you need - you can turn a division into a
&lt;br&gt;sum of several binary divisions:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://piclist.com/techref/method/math/divconst.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://piclist.com/techref/method/math/divconst.htm&lt;/a&gt;&lt;br&gt;&lt;br&gt;There is an online code generator here, though it only goes up to 32
&lt;br&gt;bits, but you probably don't care about the code generated, just the
&lt;br&gt;binary division factors:
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/techref/piclist/codegen/constdivmul.htm&lt;/a&gt;&lt;br&gt;&lt;br&gt;1/125 = 0.008, which happens to be very close to:
&lt;br&gt;&lt;br&gt;; ALGORITHM:
&lt;br&gt;; Clear accumulator
&lt;br&gt;; Add input / 128 to accumulator
&lt;br&gt;; Add input / 8192 to accumulator
&lt;br&gt;; Add input / 16384 to accumulator
&lt;br&gt;; Add input / 262144 to accumulator
&lt;br&gt;; Move accumulator to result
&lt;br&gt;;
&lt;br&gt;; Approximated constant: 0.00799942, Error: 0.00724792 %
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&amp;Bits=32&amp;endian=little&amp;Const=.008&amp;ConstErr=0.05&amp;Temp=TEMP&amp;cpu=pic16&lt;/a&gt;&lt;br&gt;&lt;br&gt;You can change the &amp;quot;ConstErr=0.05&amp;quot; to a finer value to reduce the error further.
&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;On Wed, Apr 29, 2009 at 3:14 AM, William &amp;quot;Chops&amp;quot; Westfield
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23298946&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;    (ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt; maintained by a timer ISR.  microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;    (ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt; least a 48bit intermediate value.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; It would be nice if the code were in C.  Avr gcc, in particular.
&lt;br&gt;&amp;gt; There are 8, 16, 32, and even 64 bit math functions available, but of
&lt;br&gt;&amp;gt; course they're *C*, so they don't let you actually do mixed-sized
&lt;br&gt;&amp;gt; math, nor are they likely to optimized
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The code is not particularly time critical, but it would be nice if it
&lt;br&gt;&amp;gt; were as small and fast as possible (using 64bit long longs seems
&lt;br&gt;&amp;gt; excessive.)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thoughts?  Any pointers to mixed-size C math functions in general?  In
&lt;br&gt;&amp;gt; principle, I think I understand how to do this, but ...  Is there a
&lt;br&gt;&amp;gt; way to take advantage of the constant?  Of 125 in particular?  (lots
&lt;br&gt;&amp;gt; of one bits there...)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt; Bill W
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23298946.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23295382</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T04:19:50Z</published>
	<updated>2009-04-29T04:19:50Z</updated>
	<author>
		<name>Dave Tweed</name>
	</author>
	<content type="html">William &amp;quot;Chops&amp;quot; Westfield wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt; maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt; least a 48bit intermediate value.
&lt;/div&gt;&lt;br&gt;Do you have access to the ISR? I would be inclined to do the following,
&lt;br&gt;rather than (or in addition to) simply counting the raw ticks:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /* microseconds can be a 16-bit integer */
&lt;br&gt;&amp;nbsp; &amp;nbsp; microseconds += microsecondsPerTick;
&lt;br&gt;&amp;nbsp; &amp;nbsp; while (microseconds &amp;gt;= 1000) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; microseconds -= 1000;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ++milliseconds;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;-- Dave Tweed
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23295382.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23295220</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T04:07:49Z</published>
	<updated>2009-04-29T04:07:49Z</updated>
	<author>
		<name>Walter Banks</name>
	</author>
	<content type="html">48 bits by 125
&lt;br&gt;&lt;br&gt;&lt;br&gt;I would use a grade school divide and nybble away at the 48 bit number
&lt;br&gt;something like
&lt;br&gt;&lt;br&gt;unsigned char i48[5]; &amp;nbsp;// 48 bit number
&lt;br&gt;unsigned char r48[5]; &amp;nbsp;// Result
&lt;br&gt;&lt;br&gt;unsigned char m,r; &amp;nbsp; &amp;nbsp; // most , least and result
&lt;br&gt;signed char l; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // signed so some compilers can check better for
&lt;br&gt;negative than &amp;gt; 128
&lt;br&gt;&lt;br&gt;// init the most and least significant numbers
&lt;br&gt;&amp;nbsp; m = i48[0];
&lt;br&gt;&amp;nbsp; l = i48[1];
&lt;br&gt;&lt;br&gt;&lt;br&gt;for (char i = 2; i != 5; i++)
&lt;br&gt;{
&lt;br&gt;&lt;br&gt;for (char j = 8; i != 0; i--) &amp;nbsp;// should be optimizede to a repeat .. until
&lt;br&gt;&amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp;r &amp;lt;&amp;lt;= 1; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// No need to init all the bits will be shifted out
&lt;br&gt;&amp;nbsp; &amp;nbsp;if (m &amp;gt; 250) &amp;nbsp; &amp;nbsp; &amp;nbsp;// 125 shifted up by 1
&lt;br&gt;&amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; m -= 250;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; r += 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;// shift m:l left
&lt;br&gt;&amp;nbsp; &amp;nbsp;m &amp;lt;&amp;lt;= 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp;if (l &amp;lt; 0) m += 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp;l &amp;lt;&amp;lt;= 1;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;r48[i-2] = r;
&lt;br&gt;l = i48[i+1];
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;// Run out the last byte
&lt;br&gt;&lt;br&gt;for (char j = 8; i != 0; i--) &amp;nbsp;// should be optimizede to a repeat .. until
&lt;br&gt;&amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp;r48[4] &amp;lt;&amp;lt;= 1; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// No need to init all the bits will be shifted out
&lt;br&gt;&amp;nbsp; &amp;nbsp;if (m &amp;gt; 250) &amp;nbsp; &amp;nbsp; &amp;nbsp;// 125 shifted up by 1
&lt;br&gt;&amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; m -= 250;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; r48[4] += 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp;m &amp;lt;&amp;lt;= 1;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;&lt;br&gt;This shouldn't generate much code all of the operations are byte sized.
&lt;br&gt;Using 18037 support the shifts and tests should be able to be optimized to
&lt;br&gt;a single 8 bit subtract and three shifts.
&lt;br&gt;&lt;br&gt;The over all result probably is out by a factor of two for the 125 to 250
&lt;br&gt;doubling.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;Walter Banks
&lt;br&gt;Byte Craft Limited
&lt;br&gt;&lt;a href=&quot;http://www.bytecraft.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.bytecraft.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23295220.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23294080</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T02:48:09Z</published>
	<updated>2009-04-29T02:48:09Z</updated>
	<author>
		<name>Tamas Rudnai</name>
	</author>
	<content type="html">Is the 'microsecondsPerTick' known during the compile time? How long would
&lt;br&gt;it do that with float? (which is 32 bit only so may affects the accuracy).
&lt;br&gt;&lt;br&gt;Tamas
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Wed, Apr 29, 2009 at 8:14 AM, William &amp;quot;Chops&amp;quot; Westfield
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23294080&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt;wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I want to calculate:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to return the number of milliseconds elapsed based on a count
&lt;br&gt;&amp;gt; maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant
&lt;br&gt;&amp;gt; number like 1024 or 2048, so the multiplication becomes a shift, and
&lt;br&gt;&amp;gt; factoring out twos I get:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT
&lt;br&gt;&amp;gt; OVERFLOW (been there, trying to fix that!), so I'm looking at at at
&lt;br&gt;&amp;gt; least a 48bit intermediate value.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; It would be nice if the code were in C. &amp;nbsp;Avr gcc, in particular.
&lt;br&gt;&amp;gt; There are 8, 16, 32, and even 64 bit math functions available, but of
&lt;br&gt;&amp;gt; course they're *C*, so they don't let you actually do mixed-sized
&lt;br&gt;&amp;gt; math, nor are they likely to optimized
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The code is not particularly time critical, but it would be nice if it
&lt;br&gt;&amp;gt; were as small and fast as possible (using 64bit long longs seems
&lt;br&gt;&amp;gt; excessive.)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thoughts? &amp;nbsp;Any pointers to mixed-size C math functions in general? &amp;nbsp;In
&lt;br&gt;&amp;gt; principle, I think I understand how to do this, but ... &amp;nbsp;Is there a
&lt;br&gt;&amp;gt; way to take advantage of the constant? &amp;nbsp;Of 125 in particular? &amp;nbsp;(lots
&lt;br&gt;&amp;gt; of one bits there...)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt; Bill W
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.mcuhobby.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mcuhobby.com&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23294080.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23293062</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T01:41:32Z</published>
	<updated>2009-04-29T01:41:32Z</updated>
	<author>
		<name>sergio masci-2</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On Wed, 29 Apr 2009, William &amp;quot;Chops&amp;quot; Westfield wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; Thoughts? &amp;nbsp;Any pointers to mixed-size C math functions in general? &amp;nbsp;In &amp;nbsp;
&lt;br&gt;&amp;gt; principle, I think I understand how to do this, but ... &amp;nbsp;Is there a &amp;nbsp;
&lt;br&gt;&amp;gt; way to take advantage of the constant? &amp;nbsp;Of 125 in particular? &amp;nbsp;(lots &amp;nbsp;
&lt;br&gt;&amp;gt; of one bits there...)
&lt;br&gt;&lt;br&gt;Are you able to do this with 5 16 bit by 8 bit divisons?
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Sergio Masci
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23293062.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23292631</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T01:09:00Z</published>
	<updated>2009-04-29T01:09:00Z</updated>
	<author>
		<name>Alan B. Pearce-2</name>
	</author>
	<content type="html">&amp;gt;How much error can you stand?
&lt;br&gt;&amp;gt;125 is pretty close to 128. &amp;nbsp;:-)
&lt;br&gt;&lt;br&gt;Well, from what he is saying, not much error.
&lt;br&gt;&lt;br&gt;But I was wondering - just thinking outside the box here - if it is possible 
&lt;br&gt;to change the clock frequency of the micro enough to make the 125 become 128 
&lt;br&gt;...
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23292631.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23292322</id>
	<title>Re: divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T00:44:20Z</published>
	<updated>2009-04-29T00:44:20Z</updated>
	<author>
		<name>Charles Craft</name>
	</author>
	<content type="html">How much error can you stand?
&lt;br&gt;125 is pretty close to 128. &amp;nbsp;:-)
&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;From: &amp;quot;William \&amp;quot;Chops\&amp;quot; Westfield&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23292322&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;westfw@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;Sent: Apr 29, 2009 3:14 AM
&lt;br&gt;&amp;gt;To: &amp;quot;Microcontroller discussion list - Public.&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=23292322&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;piclist@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;Subject: [AVR] divide 48bit number by (constant) 125 ?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;I want to calculate:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;to return the number of milliseconds elapsed based on a count &amp;nbsp;
&lt;br&gt;&amp;gt;maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant &amp;nbsp;
&lt;br&gt;&amp;gt;number like 1024 or 2048, so the multiplication becomes a shift, and &amp;nbsp;
&lt;br&gt;&amp;gt;factoring out twos I get:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;(ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT &amp;nbsp;
&lt;br&gt;&amp;gt;OVERFLOW (been there, trying to fix that!), so I'm looking at at at &amp;nbsp;
&lt;br&gt;&amp;gt;least a 48bit intermediate value.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;It would be nice if the code were in C. &amp;nbsp;Avr gcc, in particular. &amp;nbsp; 
&lt;br&gt;&amp;gt;There are 8, 16, 32, and even 64 bit math functions available, but of &amp;nbsp;
&lt;br&gt;&amp;gt;course they're *C*, so they don't let you actually do mixed-sized &amp;nbsp;
&lt;br&gt;&amp;gt;math, nor are they likely to optimized
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;The code is not particularly time critical, but it would be nice if it &amp;nbsp;
&lt;br&gt;&amp;gt;were as small and fast as possible (using 64bit long longs seems &amp;nbsp;
&lt;br&gt;&amp;gt;excessive.)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;Thoughts? &amp;nbsp;Any pointers to mixed-size C math functions in general? &amp;nbsp;In &amp;nbsp;
&lt;br&gt;&amp;gt;principle, I think I understand how to do this, but ... &amp;nbsp;Is there a &amp;nbsp;
&lt;br&gt;&amp;gt;way to take advantage of the constant? &amp;nbsp;Of 125 in particular? &amp;nbsp;(lots &amp;nbsp;
&lt;br&gt;&amp;gt;of one bits there...)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;Thanks
&lt;br&gt;&amp;gt;Bill W
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;-- 
&lt;br&gt;&amp;gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt;View/change your membership options at
&lt;br&gt;&amp;gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23292322.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-23291971</id>
	<title>divide 48bit number by (constant) 125 ?</title>
	<published>2009-04-29T00:14:52Z</published>
	<updated>2009-04-29T00:14:52Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">I want to calculate:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; (ticks * &amp;lt;microsecondsPerTick&amp;gt;) / 1000
&lt;br&gt;&lt;br&gt;to return the number of milliseconds elapsed based on a count &amp;nbsp;
&lt;br&gt;maintained by a timer ISR. &amp;nbsp;microsecondsPerTick is a nice constant &amp;nbsp;
&lt;br&gt;number like 1024 or 2048, so the multiplication becomes a shift, and &amp;nbsp;
&lt;br&gt;factoring out twos I get:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; (ticks * (microsecondsPerTick/8)) / 125
&lt;br&gt;&lt;br&gt;&amp;quot;ticks&amp;quot; is at least 40 bits, however, and the multiplication MUST NOT &amp;nbsp;
&lt;br&gt;OVERFLOW (been there, trying to fix that!), so I'm looking at at at &amp;nbsp;
&lt;br&gt;least a 48bit intermediate value.
&lt;br&gt;&lt;br&gt;It would be nice if the code were in C. &amp;nbsp;Avr gcc, in particular. &amp;nbsp; 
&lt;br&gt;There are 8, 16, 32, and even 64 bit math functions available, but of &amp;nbsp;
&lt;br&gt;course they're *C*, so they don't let you actually do mixed-sized &amp;nbsp;
&lt;br&gt;math, nor are they likely to optimized
&lt;br&gt;&lt;br&gt;The code is not particularly time critical, but it would be nice if it &amp;nbsp;
&lt;br&gt;were as small and fast as possible (using 64bit long longs seems &amp;nbsp;
&lt;br&gt;excessive.)
&lt;br&gt;&lt;br&gt;Thoughts? &amp;nbsp;Any pointers to mixed-size C math functions in general? &amp;nbsp;In &amp;nbsp;
&lt;br&gt;principle, I think I understand how to do this, but ... &amp;nbsp;Is there a &amp;nbsp;
&lt;br&gt;way to take advantage of the constant? &amp;nbsp;Of 125 in particular? &amp;nbsp;(lots &amp;nbsp;
&lt;br&gt;of one bits there...)
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;Bill W
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/divide-48bit-number-by-%28constant%29-125---tp23291971p23291971.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-19471962</id>
	<title>Re: Debugging / Simulating</title>
	<published>2008-09-13T08:50:12Z</published>
	<updated>2008-09-13T08:50:12Z</updated>
	<author>
		<name>Pete Calinski</name>
	</author>
	<content type="html">I don't know anything about Linux.
&lt;br&gt;&lt;br&gt;&lt;br&gt;----- Original Message ----- 
&lt;br&gt;From: &amp;quot;Tamas Rudnai&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=19471962&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tamas.rudnai@...&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &amp;quot;Microcontroller discussion list - Public.&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=19471962&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;piclist@...&lt;/a&gt;&amp;gt;
&lt;br&gt;Sent: Thursday, September 11, 2008 6:29 AM
&lt;br&gt;Subject: [AVR] Debugging / Simulating
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello There,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I am just studying the GNU toolchain on Linux, how could I use it for real
&lt;br&gt;&amp;gt; purposes. My current problem is that there is no symbolic information on 
&lt;br&gt;&amp;gt; IO
&lt;br&gt;&amp;gt; registers, like PORTB. So if I say &amp;quot;p/x PORTB&amp;quot; it does not work. I can say
&lt;br&gt;&amp;gt; &amp;quot;x/x 0x800038&amp;quot; but this is so ugly - and of course if I use ddd then it
&lt;br&gt;&amp;gt; looks even worse in the data view window.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Couple of questoins:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1. Any way to get symbols for these things?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 2. Is there any place where I could download avr-insight compiled for i386 
&lt;br&gt;&amp;gt; /
&lt;br&gt;&amp;gt; P4 etc (using ubuntu)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 3. ...If not is there any place which describes for a dummy like me how to
&lt;br&gt;&amp;gt; get that compiled, how to merge insight with avr-gdb etc?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt; Tamas
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; Rudonix DoubleSaver
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.rudonix.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.rudonix.com&lt;/a&gt;&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&amp;nbsp;
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Debugging---Simulating-tp19431988p19471962.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-19431988</id>
	<title>Debugging / Simulating</title>
	<published>2008-09-11T03:29:35Z</published>
	<updated>2008-09-11T03:29:35Z</updated>
	<author>
		<name>Tamas Rudnai</name>
	</author>
	<content type="html">Hello There,
&lt;br&gt;&lt;br&gt;I am just studying the GNU toolchain on Linux, how could I use it for real
&lt;br&gt;purposes. My current problem is that there is no symbolic information on IO
&lt;br&gt;registers, like PORTB. So if I say &amp;quot;p/x PORTB&amp;quot; it does not work. I can say
&lt;br&gt;&amp;quot;x/x 0x800038&amp;quot; but this is so ugly - and of course if I use ddd then it
&lt;br&gt;looks even worse in the data view window.
&lt;br&gt;&lt;br&gt;Couple of questoins:
&lt;br&gt;&lt;br&gt;1. Any way to get symbols for these things?
&lt;br&gt;&lt;br&gt;2. Is there any place where I could download avr-insight compiled for i386 /
&lt;br&gt;P4 etc (using ubuntu)
&lt;br&gt;&lt;br&gt;3. ...If not is there any place which describes for a dummy like me how to
&lt;br&gt;get that compiled, how to merge insight with avr-gdb etc?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;Tamas
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Rudonix DoubleSaver
&lt;br&gt;&lt;a href=&quot;http://www.rudonix.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.rudonix.com&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Debugging---Simulating-tp19431988p19431988.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18991159</id>
	<title>Re: Programming specification, where?</title>
	<published>2008-08-14T15:50:41Z</published>
	<updated>2008-08-14T15:50:41Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">&lt;br&gt;On Aug 7, 2008, at 3:42 AM, Shawn Tan wrote:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; is there a binary level specification for the opcodes of AVRs? I &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; have the assembly programming specification and I hope to find it &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; there.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Oh, so what you were looking for is the &amp;quot;instruction set&amp;quot; of the AVRs.
&lt;br&gt;&lt;br&gt;See also &lt;a href=&quot;http://www.geocities.com/westfw/avr-instructionset.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.geocities.com/westfw/avr-instructionset.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;This is a &amp;quot;decode table&amp;quot; for converting Hex opcodes to actual &amp;nbsp;
&lt;br&gt;instructions, and gives a quick overview of the instruction set, as &amp;nbsp;
&lt;br&gt;well as being &amp;quot;interesting&amp;quot; in its relative randomness. &amp;nbsp;It's clear &amp;nbsp; 
&lt;br&gt;(IMMO) that the AVR is a very &amp;quot;top down&amp;quot; digital design...
&lt;br&gt;&lt;br&gt;BillW
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Programming-specification%2C-where--tp18809142p18991159.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18974060</id>
	<title>Do you need PCB</title>
	<published>2008-08-13T18:01:26Z</published>
	<updated>2008-08-13T18:01:26Z</updated>
	<author>
		<name>hanward</name>
	</author>
	<content type="html">Hello,all.we are a PCB manufacturer.Material:FR-4,aluminium,FPC.Layer: 1-10,thickness:0.4-4.2mm,min.Line/Space:0.1mm,min.hole:0.1mm,inculding burried/blind hole.Both prototype and mass production are welcome.
&lt;br&gt;Details pls send me email by hanward@szckt.cn or contact me at:
&lt;br&gt;Contacting:Hanward Jiang
&lt;br&gt;&lt;br&gt;Marketing Dept.Manager
&lt;br&gt;Cirket Electronics Company
&lt;br&gt;22A,Block B,Nanhai Bldg,Nanshan Rd,
&lt;br&gt;Shenzhen,P.R.China
&lt;br&gt;Tel:+86-755-8621 5150
&lt;br&gt;Fax:+86-755-8621 5160
&lt;br&gt;MSN:hanwardjiang@hotmail.com
&lt;br&gt;Skype: hanward
&lt;br&gt;Website:www.szckt.cn
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Do-you-need-PCB-tp18974060p18974060.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18867946</id>
	<title>Re: Programming specification, where?</title>
	<published>2008-08-07T03:42:24Z</published>
	<updated>2008-08-07T03:42:24Z</updated>
	<author>
		<name>Shawn Tan Ser Ngiap</name>
	</author>
	<content type="html">On Thursday 07 August 2008 11:04:34 Peter wrote:
&lt;br&gt;&amp;gt; &amp;gt; Atmel places programming information for each chip in that chip's
&lt;br&gt;&amp;gt; &amp;gt; datasheet - it's not a seperate document.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks for that, I found it now. Still, is there a binary level
&lt;br&gt;&amp;gt; specification for the opcodes of AVRs? I have the assembly programming
&lt;br&gt;&amp;gt; specification and I hope to find it there.
&lt;br&gt;&lt;br&gt;Oh, so what you were looking for is the &amp;quot;instruction set&amp;quot; of the AVRs. Google 
&lt;br&gt;for &amp;quot;AVR instruction set&amp;quot; and it's the very first document. The binary opcodes 
&lt;br&gt;are listed.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;with metta,
&lt;br&gt;Shawn Tan
&lt;br&gt;&lt;br&gt;Aeste Works (M) Sdn Bhd - Engineering Elegance
&lt;br&gt;&lt;a href=&quot;http://www.aeste.net&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.aeste.net&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Programming-specification%2C-where--tp18809142p18867946.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18867482</id>
	<title>Re: Programming specification, where?</title>
	<published>2008-08-07T03:04:34Z</published>
	<updated>2008-08-07T03:04:34Z</updated>
	<author>
		<name>plpeter</name>
	</author>
	<content type="html">&amp;gt; Atmel places programming information for each chip in that chip's
&lt;br&gt;&amp;gt; datasheet - it's not a seperate document.
&lt;br&gt;&lt;br&gt;Thanks for that, I found it now. Still, is there a binary level specification
&lt;br&gt;for the opcodes of AVRs? I have the assembly programming specification and I
&lt;br&gt;hope to find it there.
&lt;br&gt;&lt;br&gt;thanks,
&lt;br&gt;Peter
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Programming-specification%2C-where--tp18809142p18867482.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18811855</id>
	<title>Re: Programming specification, where?</title>
	<published>2008-08-04T06:50:33Z</published>
	<updated>2008-08-04T06:50:33Z</updated>
	<author>
		<name>M. Adam Davis-2</name>
	</author>
	<content type="html">Atmel places programming information for each chip in that chip's
&lt;br&gt;datasheet - it's not a seperate document.
&lt;br&gt;&lt;br&gt;For instance, you can look at section 27 of the atmega168 document for
&lt;br&gt;instructions on both parallel and serial memory programming modes:
&lt;br&gt;&lt;a href=&quot;http://atmel.com/dyn/resources/prod_documents/doc2545.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://atmel.com/dyn/resources/prod_documents/doc2545.pdf&lt;/a&gt;&lt;br&gt;&lt;br&gt;Find the full datasheet for the chip you want to program, and check
&lt;br&gt;out the section labeled, &amp;quot;Memory Programming&amp;quot;
&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;On 8/4/08, Peter &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=18811855&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;plpeter2006@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Could anyone please point me towards the official pdf format memory programming
&lt;br&gt;&amp;gt; specification for AVR micros? I.e. the equivalent of the Microchip Memory
&lt;br&gt;&amp;gt; Programming Specification that shows most pin-out and timing issues needed to
&lt;br&gt;&amp;gt; program a Pic, but for an AVR? And, since on is at that, to the bit level
&lt;br&gt;&amp;gt; instruction encoding specifications for AVRs?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Neither Google nor the peruse of forums and of the Atmel site helped here
&lt;br&gt;&amp;gt; (unlike Microchip's site where such information is linked directly from the
&lt;br&gt;&amp;gt; device home page).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; thanks,
&lt;br&gt;&amp;gt; Peter
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;&amp;gt; View/change your membership options at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;EARTH DAY 2008
&lt;br&gt;Tuesday April 22
&lt;br&gt;Save Money * Save Oil * Save Lives * Save the Planet
&lt;br&gt;&lt;a href=&quot;http://www.driveslowly.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.driveslowly.org&lt;/a&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Programming-specification%2C-where--tp18809142p18811855.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-18809142</id>
	<title>Programming specification, where?</title>
	<published>2008-08-04T03:48:36Z</published>
	<updated>2008-08-04T03:48:36Z</updated>
	<author>
		<name>plpeter</name>
	</author>
	<content type="html">Could anyone please point me towards the official pdf format memory programming
&lt;br&gt;specification for AVR micros? I.e. the equivalent of the Microchip Memory
&lt;br&gt;Programming Specification that shows most pin-out and timing issues needed to
&lt;br&gt;program a Pic, but for an AVR? And, since on is at that, to the bit level
&lt;br&gt;instruction encoding specifications for AVRs?
&lt;br&gt;&lt;br&gt;Neither Google nor the peruse of forums and of the Atmel site helped here
&lt;br&gt;(unlike Microchip's site where such information is linked directly from the
&lt;br&gt;device home page).
&lt;br&gt;&lt;br&gt;thanks,
&lt;br&gt;Peter
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Programming-specification%2C-where--tp18809142p18809142.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17445789</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-24T01:34:41Z</published>
	<updated>2008-05-24T01:34:41Z</updated>
	<author>
		<name>BryanW-3</name>
	</author>
	<content type="html">On Sat, May 24, 2008 at 12:16 AM, John Samperi
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=17445789&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;samperi@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; At 08:13 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;&amp;gt;The original AVRISP from the company that designed the original AVR
&lt;br&gt;&amp;gt;&amp;gt;starter kits, now works from USB.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; $59.00?? What do you get for the extra cost than an
&lt;br&gt;&amp;gt; AVRISP?...well apart from the 10W to 6 way adaptor,
&lt;br&gt;&amp;gt; or is that extra? :-)
&lt;br&gt;&lt;br&gt;USB and NO firmware. So it won't update and never work again. Also its
&lt;br&gt;the real price not the subsidised by marketing price. Oh and it has an
&lt;br&gt;avrstudio plugin too, if you don't want to leave studio.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17445789.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17442851</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T16:49:55Z</published>
	<updated>2008-05-23T16:49:55Z</updated>
	<author>
		<name>John Samperi</name>
	</author>
	<content type="html">At 09:36 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;Are you basing that on actual experience with cheap AVR programmers?
&lt;br&gt;&lt;br&gt;I'm basing it on 7 years helping out people on Avrfreaks that
&lt;br&gt;kill their chips with cheap programmer, especially parallel port
&lt;br&gt;programmer with their confusing hex fuse setting software.
&lt;br&gt;&lt;br&gt;For me, I just do not want to exit Studio, all that I need is in
&lt;br&gt;one IDE which works fairly well...apart from the occasional bug...
&lt;br&gt;&lt;br&gt;Having said that I started off with a PPP with the 4 resistors,
&lt;br&gt;(233 MHz processor win 3.11) but once I started to use AVRs for
&lt;br&gt;real I got an AVRISP, it just works.
&lt;br&gt;&lt;br&gt;I also have a STK500 and a Dragon which can be used as backup
&lt;br&gt;programmers.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;John Samperi
&lt;br&gt;&lt;br&gt;********************************************************
&lt;br&gt;Ampertronics Pty. Ltd.
&lt;br&gt;11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
&lt;br&gt;Tel. (02) 9674-6495 &amp;nbsp; &amp;nbsp; &amp;nbsp; Fax (02) 9674-8745
&lt;br&gt;Email: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=17442851&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;john@...&lt;/a&gt;
&lt;br&gt;Website &amp;nbsp;&lt;a href=&quot;http://www.ampertronics.com.au&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ampertronics.com.au&lt;/a&gt;&lt;br&gt;*Electronic Design * Custom Products * Contract Assembly
&lt;br&gt;********************************************************
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17442851.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17442780</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T16:36:30Z</published>
	<updated>2008-05-23T16:36:30Z</updated>
	<author>
		<name>William &quot;Chops&quot; Westfield</name>
	</author>
	<content type="html">&amp;gt;&amp;gt; DO NOT FALL for cheap programmers!! They cost a LOT more
&lt;br&gt;&amp;gt;&amp;gt; in wasted time and dead chips.
&lt;br&gt;&lt;br&gt;Are you basing that on actual experience with cheap AVR programmers? &amp;nbsp; 
&lt;br&gt;My impression has been that due to fewer changes in technology, fewer &amp;nbsp;
&lt;br&gt;chips, and perhaps a more forward-thinking algorithm, the &amp;quot;cheap&amp;quot; AVR &amp;nbsp;
&lt;br&gt;programmers were more reliable than cheap PIC programmers, for example.
&lt;br&gt;&lt;br&gt;For instance, the cheap tiny11 programmer (serial port bit-bang) that &amp;nbsp;
&lt;br&gt;I built works better than my STK-500 (which I never got to work for &amp;nbsp;
&lt;br&gt;tiny11s.)
&lt;br&gt;&lt;br&gt;OTOH, many of the cheap designs use the PC parallel port, which is &amp;nbsp;
&lt;br&gt;likely to have all the same problems of other parallel port &amp;nbsp;
&lt;br&gt;programmers on modern PCs.
&lt;br&gt;&lt;br&gt;BillW
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17442780.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17442638</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T16:16:12Z</published>
	<updated>2008-05-23T16:16:12Z</updated>
	<author>
		<name>John Samperi</name>
	</author>
	<content type="html">At 08:13 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;The original AVRISP from the company that designed the original AVR
&lt;br&gt;&amp;gt;starter kits, now works from USB.
&lt;br&gt;&lt;br&gt;$59.00?? What do you get for the extra cost than an
&lt;br&gt;AVRISP?...well apart from the 10W to 6 way adaptor,
&lt;br&gt;or is that extra? :-)
&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;John Samperi
&lt;br&gt;&lt;br&gt;********************************************************
&lt;br&gt;Ampertronics Pty. Ltd.
&lt;br&gt;11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
&lt;br&gt;Tel. (02) 9674-6495 &amp;nbsp; &amp;nbsp; &amp;nbsp; Fax (02) 9674-8745
&lt;br&gt;Email: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=17442638&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;john@...&lt;/a&gt;
&lt;br&gt;Website &amp;nbsp;&lt;a href=&quot;http://www.ampertronics.com.au&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ampertronics.com.au&lt;/a&gt;&lt;br&gt;*Electronic Design * Custom Products * Contract Assembly
&lt;br&gt;********************************************************
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17442638.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17441983</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T15:13:36Z</published>
	<updated>2008-05-23T15:13:36Z</updated>
	<author>
		<name>BryanW-3</name>
	</author>
	<content type="html">On Fri, May 23, 2008 at 10:34 PM, John Samperi
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=17441983&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;samperi@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; At 05:23 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;&amp;gt;Last &amp;nbsp;time I looked into programming an Atmel, I found some low-cost
&lt;br&gt;&amp;gt;&amp;gt;entry-level programmers at sparkfun.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; DO NOT FALL for cheap programmers!! They cost a LOT more
&lt;br&gt;&amp;gt; in wasted time and dead chips.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The price of a real AVRISP is nothing even for a hobbiest,
&lt;br&gt;&amp;gt; so for a professional like James it should be a mandatory
&lt;br&gt;&amp;gt; purchase. :-)
&lt;/div&gt;&lt;br&gt;The original AVRISP from the company that designed the original AVR
&lt;br&gt;starter kits, now works from USB.
&lt;br&gt;&lt;a href=&quot;http://www.kanda.com/products/Kanda/AVRISP-U.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.kanda.com/products/Kanda/AVRISP-U.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;And a note, Our handheld standalone programmer product is programmable
&lt;br&gt;with USB also.
&lt;br&gt;&lt;a href=&quot;http://www.kanda.com/products/Kanda/HH0010U.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.kanda.com/products/Kanda/HH0010U.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;Contact support or sales @ kanda.com and we will add any device which
&lt;br&gt;may not be at this time supported. We try to keep the device support
&lt;br&gt;up to date, but sometimes Atmel sneaks them past us. :)
&lt;br&gt;&lt;br&gt;BryanW
&lt;br&gt;Software Engineer, Embedded Results ltd, t/a kanda.com
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17441983.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17441843</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T14:59:40Z</published>
	<updated>2008-05-23T14:59:40Z</updated>
	<author>
		<name>Brian B. Riley</name>
	</author>
	<content type="html">... amen ... Atmel's AVRISP mkII In System Programmer is Mouser p/n: &amp;nbsp;
&lt;br&gt;556-ATAVRISP2 and sells for $35.91 in qty=1! (plus shipping of course) &amp;nbsp;
&lt;br&gt;It will, among many others, program an 8515.
&lt;br&gt;&lt;br&gt;&lt;br&gt;On May 23, 2008, at 5:34 PM, John Samperi wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; At 05:23 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;&amp;gt; Last &amp;nbsp;time I looked into programming an Atmel, I found some low-cost
&lt;br&gt;&amp;gt;&amp;gt; entry-level programmers at sparkfun.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; DO NOT FALL for cheap programmers!! They cost a LOT more
&lt;br&gt;&amp;gt; in wasted time and dead chips.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The price of a real AVRISP is nothing even for a hobbiest,
&lt;br&gt;&amp;gt; so for a professional like James it should be a mandatory
&lt;br&gt;&amp;gt; purchase. :-)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; John Samperi
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;cheers ... 73 de brian &amp;nbsp;riley, &amp;nbsp;n1bq , underhill center, vermont
&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;lt;&lt;a href=&quot;http://web.mac.com/brianbr/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://web.mac.com/brianbr/&lt;/a&gt;&amp;gt; &amp;nbsp;Tech Blog
&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;lt;&lt;a href=&quot;http://www.wulfden.org/TheShoppe.shtml&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.wulfden.org/TheShoppe.shtml&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;nbsp; &amp;nbsp; Home of the
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;K107 Serial LCD Controller Kit &amp;nbsp; &amp;nbsp;FT817 Power Conditioner Kit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Tab Robot Laser Tag Kit &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MSP430 Chips and Connectors
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Propeller Robot Controller &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SX48 &amp;quot;Tech Board&amp;quot; Kit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PICAXE chips and accessories &amp;nbsp; Freeduino systems
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17441843.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-17441515</id>
	<title>Re: What does it take to program an ATMEGA 8515?</title>
	<published>2008-05-23T14:34:10Z</published>
	<updated>2008-05-23T14:34:10Z</updated>
	<author>
		<name>John Samperi</name>
	</author>
	<content type="html">At 05:23 AM 24/05/2008, you wrote:
&lt;br&gt;&amp;gt;Last &amp;nbsp;time I looked into programming an Atmel, I found some low-cost
&lt;br&gt;&amp;gt;entry-level programmers at sparkfun.
&lt;br&gt;&lt;br&gt;DO NOT FALL for cheap programmers!! They cost a LOT more
&lt;br&gt;in wasted time and dead chips.
&lt;br&gt;&lt;br&gt;The price of a real AVRISP is nothing even for a hobbiest,
&lt;br&gt;so for a professional like James it should be a mandatory
&lt;br&gt;purchase. :-)
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;John Samperi
&lt;br&gt;&lt;br&gt;********************************************************
&lt;br&gt;Ampertronics Pty. Ltd.
&lt;br&gt;11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
&lt;br&gt;Tel. (02) 9674-6495 &amp;nbsp; &amp;nbsp; &amp;nbsp; Fax (02) 9674-8745
&lt;br&gt;Email: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=17441515&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;john@...&lt;/a&gt;
&lt;br&gt;Website &amp;nbsp;&lt;a href=&quot;http://www.ampertronics.com.au&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ampertronics.com.au&lt;/a&gt;&lt;br&gt;*Electronic Design * Custom Products * Contract Assembly
&lt;br&gt;********************************************************
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.piclist.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.piclist.com&lt;/a&gt;&amp;nbsp;PIC/SX FAQ &amp; list archive
&lt;br&gt;View/change your membership options at
&lt;br&gt;&lt;a href=&quot;http://mailman.mit.edu/mailman/listinfo/piclist&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mailman.mit.edu/mailman/listinfo/piclist&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/What-does-it-take-to-program-an-ATMEGA-8515--tp17432079p17441515.html" />
</entry>

</feed>
