piclist 2008\07\28\204924a >
Thread: Multiplication/ Division
www.piclist.com/techref/microchip/math/index.htm?key=multiplication
picon face BY : Tomás Ó hÉilidheemail (remove spam text)





threewheeler7 wrote:
> is it possible to do multiplication or division on two registers, instead of
> one being a literal constant?


Ehm I sure hope so, otherwise I think you'd have a crippled processor.
Take the following simple code for instance:

   int i = GetInputFromPortOrWhatever();

   int j = GetInputFromPortOrWhatever();

   PORTC = i * j;


>  lets say i have a routine that flashes an led
> "x" number of times with "t" amount of time between flashes. i would like to
> write a routine that instead of feeding the first routine t; it would take
> the "total time" (in ms) i want the flashing routine to run for, and divide
> it by "x", to get "t". so each time it is executed, "x" and "total time" may
> me different.


I did something very similar to this in my Connect4 project. Reading
your paragraph above I can only assume that the LED is on for the same
amount of time that it's off.

(Disclaimer: Rushed, unchecked code likely to contain a bug or two)

void FlashLED(unsigned const amount_flashes, long unsigned const
total_duration)
{
   long unsigned const delay = duration / amount_flashes / 2;

   do
   {
       RA0 = 1;
       Delay_Ms(delay);

       RA0 = 0;
       Delay_Ms(delay);
   } while (--amount_times);
}

<488E68ED.80904@lavabit.com> 7bit

In reply to: <18702111.post@talk.nabble.com>
See also: www.piclist.com/techref/microchip/math/index.htm?key=multiplication
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Multiplication/ Division

month overview.

new search...