Defining a delay

Status
Not open for further replies.

Kryten

New Member
Is it possible to define a delay if i shall use it several times

I mean I can define ports as names for easy programming and give low or high output short names like

Code:
#define LED_OFF output_low

Can I do the same with a delay?

I looking to turn off (or on) several outputs for a short period of time (250ms)
will it make sense to do it like this?

Code:
#define LED_blink output_low delay(250ms) output_high
 
Hi,

Is it possible to define a delay if i shall use it several times

Yes, you create a subroutine for the delay_loop.

You then CALL delay_loop or GOTO delay_loop when ever you need it.

The value currently held in W can be carried into the subroutine if needed.

A Macro can be also used to do similar things.
 
Ok I might have been a bit vague. Im programming in C because im trying to control via USB
 
Mark Crosbie's Homepage

What C compiler are you using? What processor/controller? Do you want the I/O in the routine as well, or just a delay? Some compilers have libraries that have msec_delay included.
 
Im using (i belive its called) Hi Tech pic c compiler (the one that comes with mplab) and 18F4550 (PIC that is).

Im going to use 12MHz crystall and running it a 4x (48MHz)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…