Delay routines ???

General discussion on mikroC PRO for 8051.
Post Reply
Author
Message
capmarantonio
Posts: 1
Joined: 23 Jul 2018 09:40

Delay routines ???

#1 Post by capmarantonio » 23 Jul 2018 09:59

Here are some examples of outputting a serial stream ... i was hoping ... it would be ... regular ?
I note that the "delays" are in progression (~ +4 us at every "1" cumulated ...) as the bits are output ...
Not for the "0" ... delay_us (50) in these examples ???

WHY ? Please .
Problem of compiler ??? Of delay routines ???

Thank you


For a AT89c2051 ... but some problem also on PIC16F690 ...

Example1
' dat = %01001100
nb=0 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=1 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=2 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=3 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=4 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=5 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=6 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
nb=7 P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)

Example2
' Boucle ...
for nb = 0 to 7
P3.5=1 if dat.nb = 0 then delay_us(20) else delay_us(100) end if
P3.5=0 delay_us(50)
next nb

Example3
nb = 0
datw = 0xF3B6D8A4
do ' for nb = 0 to 31
P3.5 = 1
select case datw.nb ' dat.nb
case 0 delay_us(20)
case 1 delay_us(100)
end select
P3.5 = 0
delay_us(50)
inc (nb)
loop until nb = 32

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Delay routines ???

#2 Post by petar.suknjaja » 24 Jul 2018 14:47

Hi,
If I understood right, you have an issue that delays are adding extra us with every delay used?
Could you send us the project that demonstrates this issue? (I'm generally interested in what oscillator settings are you using)
Kind regards,
Petar

Post Reply

Return to “mikroC PRO for 8051 General”