piclist 2008\07\28\211609a >
www.piclist.com/techref/microchip/math/index.htm?key=multiplication
BY : Apptech email (remove spam text)

> ... i would like ... a routine that ... would take ...
> the "total time" (in ms) i want the flashing routine to
> run for, and divide
> it by "x", to get "t".

You have described the solution within your question.

Question: Given total time and number of flashes in this
time, produce an expression for the time between flashes

Answer:     t_step = T_total / steps.

Here t = total_time/x

This is basic division.
You can use formal division code to do it or use something
as simple as repeated subtraction.
Note that the answer will be an integer value so that it may
take up to just under one step time too little or too much
depending on your "boundary conditions". Dealing with
boundary conditions correctly is about half of the design
________

' x = number of flashes required.
' total_time is the user provided total flashing period

' t_step is calculate time per step

TT = total_time ' avoid destroying original value

t_step = 0

While  TT > 0
increment t_step
TT = TT - x
End
_____________

Tstep will be rounded up so that total time >= required
time.
You may or may not want to reduce it by 1.
If you want x flashes and are toggling a pin after each
t_step you will have to halve the t_step value above.

Russell

<084f01c8f118\$9f0197d0\$e701a8c0@y2k> 7bit