Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 15th January 2007, 04:00 PM   #1
Question Call Them

How can i call a program that is in another assembly file.
I mean;

Our main program file in which we are working.
Code:
main
movlw   .255 
movwf   PORTB
Call   delay
movlw   .0
movwf   PORTB
call   delay
Goto $ - 6
End.
Our another file that has libraries(like delay, serial port, etcetc).
Code:
delay
movlw   255
movwf   i     ;our variable i
DecFSZ   i, F
Goto $ - 1
return
Now how can i call a delay routine in our main working file???
Ayne is offline  
Old 15th January 2007, 04:15 PM   #2
Default

A simple option is to put them in an include file, and add it at the top of the program - but a more complicated (and better?) option is to use the linker - personally I never have, I'd sooner cut and paste my common subroutines in.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 15th January 2007, 04:42 PM   #3
Default

Is there any subroutine of delay on any website???

__________________________________________________ _______________
/*Nigel Goodwin likes C complier for microcontrollers*/
/*Nigel Goodwin always use MPLABSIM simulator */
Ayne is offline  
Old 15th January 2007, 04:52 PM   #4
Default

Quote:
Originally Posted by Ayne
Is there any subroutine of delay on any website???
Look on the PICList - there's a delay code generator.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 15th January 2007, 06:35 PM   #5
Default

Ayne,

When you find the delay code generator, could you post a link to it.

I would like to have that.
mramos1 is offline  
Old 15th January 2007, 11:21 PM   #6
Default

Quote:
Originally Posted by mramos1
Ayne,

When you find the delay code generator, could you post a link to it.

I would like to have that.
Jesus! - you've got almost 1500 posts here, and you can't be bothered to look on the PICList for the blindingly obvious delay code generator?.

Here's the link! http://www.piclist.com/techref/picli...egen/delay.htm
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 16th January 2007, 12:54 AM   #7
Default

I thought if Ayne needs it and was off to find it, I could ask him for a link.

He does not have to post it. I do not see where it has to do with anything but I will go find it later. I can find the PIClist site and wing the delay code generator part.

I do stuff for others to help them out when they ask, if I can, and it was not like asking a lot.

Sorry.

I tought I would save time on something that I might use (sure I would try it and going full on PIC assembler and out of the BASIC) as well others might want it as well and be able to find it here from a link.

By the tone, I take it PICList should be something I check though I still use BASIC?
mramos1 is offline  
Old 16th January 2007, 01:16 AM   #8
Default

Online version:

http://www.piclist.com/techref/picli...egen/delay.htm

or

http://www.piclist.com/cgi-bin/delay.exe

EDIT: Never found the Windows version. But that works for me.

Last edited by mramos1; 16th January 2007 at 01:20 AM.
mramos1 is offline  
Old 16th January 2007, 07:40 AM   #9
Default

Here's a windows version - http://www.mnsi.net/~boucher/picloops.html
gregmcc is offline  
Old 16th January 2007, 01:10 PM   #10
Default

Code:
Delay X cycles (7-1030) exclusive (11 to 1034 cycles inclusive of call and return) 
From Dwayne Reid 

;10 bit delay routine providing 1 cycle resolution.  Works with both 12 & 14 bit core PICs.
;Original idea from Mike Harrison.  This version by Dwayne Reid
;
;enters with upper 8 bits of delay in DELAYU, lower 2 bits in bits 1,0 of DELAYL
;bits 7..2 in DELAYL can be used as flags for whatever purpose desired.
;returns with W destroyed
Delay10bit      ;delay is 10 bit value + 7 cycles ( + call + return, if any)
     incf        DELAYU,F        ;correct for dec & test instead of test & dec
Dly10bLoop
     comf        DELAYL,W        ;invert LSBs
     decfsz      DELAYU,F
       goto      Dly10bLoop      ;coarse delay to closest 4 cycles
     andlw       b'00000011'
     addwf       PCL,F
     nop
     nop
     nop
I want to gernate variable delays in my program
I found this on the PICLIST.

Code:
;bits 7..2 in DELAYL can be used as flags for whatever purpose desired.
What is the meaning of above line??? For what pupose i can use...Can any one gave me example???
Ayne is offline  
Old 16th January 2007, 01:15 PM   #11
Default

Why not use the delay code generator there?, two of us have now posted direct links to it.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 16th January 2007, 03:07 PM   #12
Default

Quote:
Why not use the delay code generator there?, two of us have now posted direct links to it.
cuz i need different delays in my program.
Just like this
Quote:
movlw .34 ;delay of 34uSec
call delay
above code is just for an example...

But the code generater creat a fix delay.
Ayne is offline  
Old 16th January 2007, 03:14 PM   #13
Default

Thank u..... Nigel Goodwin , gregmcc , mramos1....
Ayne is offline  
Old 16th January 2007, 03:20 PM   #14
Default

Quote:
Originally Posted by Ayne
cuz i need different delays in my program.
Just like this

above code is just for an example...

But the code generater creat a fix delay.
What sort of range and resolution do you need?, my tutorials generally include variable delays - using a 1mS resolution (based on the code generator).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 17th January 2007, 12:45 AM   #15
Default

Ayne.

You can pick the range of delays times you need, say 1ms to 500ms (1/2 a second). I would make a 1ms delay via the online calc/delay generator.

Then convert it to a subroutine you can CALL. Each time you call it you get about 1ms (there is some overhead).

For 25ms make a loop to call it 25 times.

MPLABS has a stopwatch you can time it with too.

If you need 500ms, you can call another routine that you call 100msec and loop 5 times calling it. And of course 100msec: calls your 1ms subroutine 100 times.

Hope that makes since.
mramos1 is offline  
Reply

Tags
call

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
PLL WITH PIC AND TSA5511 savnik Micro Controllers 23 26th April 2009 08:50 PM
Problem with LCD code? spondootre Micro Controllers 15 29th April 2008 10:15 AM
DS1302 with PIC16f877 program RasCreationKing Micro Controllers 28 3rd May 2007 01:03 PM
patgen ppcv Micro Controllers 8 19th January 2005 09:01 AM
ya mari_69 Micro Controllers 4 7th June 2004 02:29 PM



All times are GMT. The time now is 09:25 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker