A timer with Celoxica RC100

Guest
Hi, somebody can tell me how can I make a counter (that count 1,6ms
and other that count microseconds) I make it:

static macro proc espera2 (time)
{
unsigned 64 i;

for (i=0; i<(time/1000000)*80000000;i++)
delay;

} // wait miliseconds


static macro proc espera (time)
{
unsigned 64 i;

for (i=0; i<(time/1000)*80000000;i++)
delay;
} // wait microseconds

but don't do it well. The clock is 80MHz.

Thats
 
etvive@wanadoo.es wrote:
Hi, somebody can tell me how can I make a counter (that count 1,6ms
and other that count microseconds) I make it:

static macro proc espera2 (time)
{
unsigned 64 i;

for (i=0; i<(time/1000000)*80000000;i++)
delay;

} // wait miliseconds


static macro proc espera (time)
{
unsigned 64 i;

for (i=0; i<(time/1000)*80000000;i++)
delay;
} // wait microseconds

but don't do it well. The clock is 80MHz.

I can't figure out if this could be homework or not, but I will say that
milliseconds are normally larger than microseconds, not smaller.

Marc
 
In message <65e317a4.0408190207.57c5db47@posting.google.com>,
etvive@wanadoo.es writes
Hi, somebody can tell me how can I make a counter (that count 1,6ms
and other that count microseconds) I make it:

static macro proc espera2 (time)
{
unsigned 64 i;

for (i=0; i<(time/1000000)*80000000;i++)
delay;

} // wait miliseconds
-- 8< - snip - 8< --

Try re-arranging the _integer_ division and multiplication.

e.g. for a wait of 5 us

(5 / 1000000) = 0
(5 / 1000000) * 80000000 = 0

5 * (80000000 / 1000000) = 400

Rich
 

Welcome to EDABoard.com

Sponsor

Back
Top