Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top