Discussion in "8051 Discussion Forum" started by    Dan51    Oct 25, 2007.
Thu Oct 25 2007, 11:49 AM
Hello all

I have just started using the SDCC compiler for 8051.
I am trying to write an assembler function (Delay) inside a C file. It has to be written in assembler because the delay has to be accurate. I then want to call this function from a C function:

mov r0, #FF
d100: djnz r0, d100

call Delay

The above code does not compile.
Is this possible to do some how?
Is there a better way to create an accurate delay function?

Thu Oct 25 2007, 12:30 PM
i guess it should be the other way

mov r0, #FF
d100: djnz r0, d100

and in main.. call delay as a function
Thu Oct 25 2007, 02:35 PM
Thanks, this is correct, but then I am not sure I know how to calcuate the time (clocks) required for calling the delay function in C. This may cause a samll error in the delay time. Am I correct?
Thu Oct 25 2007, 03:11 PM
not much.. after compiling its just a call to the function nothing much.
calling a function takes about 3 machine cycles, ret need 2 and rest is whats inside your loop
i have explained someone regarding how to calculate delay.. you can check that thread..
 Dan51 like this.
Thu Oct 25 2007, 04:51 PM
OK, thanks a lot!

Get Social


Powered by e107 Forum System


Thu Jun 11 2020, 06:27 AM
sir could please send the code for I2C and wifi interfacing with 8051
Tue May 19 2020, 10:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 07:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 01:39 PM
Sir kindly send the code file i2c for 8051
Fri Mar 13 2020, 10:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 12:55 PM
how can get hadwere of this project
Sat Mar 07 2020, 05:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 04:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 10:12 AM
Pearl Olin
Wed Jan 22 2020, 06:16 PM
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.



Thu Jun 25 2020, 03:46 PM
Mon Jun 22 2020, 03:03 PM
Tue Jun 16 2020, 05:10 PM
Sat Jun 13 2020, 09:43 PM
Thu May 21 2020, 12:44 PM
Thu May 21 2020, 01:28 AM
Wed May 20 2020, 07:05 PM
Wed May 20 2020, 11:52 AM


Guests: 101, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123