Discussion in "8051 Discussion Forum" started by    jackthegr8    Nov 9, 2009.
Mon Nov 09 2009, 05:23 pm
#1
Hey all, I do use atmel 89c2051 controller. I wanna generate a signal with 1us On time and 1us OFF time. I am tired of trying with different method. so plz suggest me some idea !!!
Mon Nov 09 2009, 05:31 pm
#2
well how much is your crystal frequency?
Mon Nov 09 2009, 06:03 pm
#3
I use 11.0592 MHZ crystal.


[ Edited Mon Nov 09 2009, 06:03 pm ]
Mon Nov 09 2009, 06:17 pm
#4
you can generate 1uS delay for the reason, your single clock cycle itself is 1.085uS. you need higher speed crystal to generate that delay.
Mon Nov 09 2009, 06:29 pm
#5
Ok. My intention is not exactly producing 2us delay. I need to generate a On time of 3 us and off time 27 us. Pulse of 10% duty cycle. and this dut cyle is variable from 10% to 90%
Mon Nov 09 2009, 08:58 pm
#6
One simple solution is to change your crystal frequency to 12Mhz to get exactly
1us / 1 Byte Command
example
2uS ON
3uS Off

main:
setb P1.0 ;1us 
nop   ;1uS 
clr P1.0 ;1us  
jmp main ;2us
 




Tue Nov 10 2009, 12:23 pm
#7
Yep, thanks for the code, but i am looking for implement the same using timer or DJNZ loop, so that I can change the delay in a generic way.I attempted using timer, but I couldn't get On or OFF period lesser than 5 ns.
Tue Nov 10 2009, 06:06 pm
#8
well you can use loops if your delay is a bit longer but DJNZ instruction itself take 2 cycles.
Wed Nov 11 2009, 02:31 pm
#9
void delay_us(unsigned int us)
{
int a=(us)/13; //BY TRIAL
while(a--);
}

11.0592*2 MHZ
Wed Nov 11 2009, 05:54 pm
#10
mov R1,#01 ;or any other value here
djnz R1,#01,decrement
decrement: dec R1


That is with a 12Mhz crystal. However, minimum with djnz is 2us!


[ Edited Wed Nov 11 2009, 05:55 pm ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Edwardcleri
Wed May 29 2024, 03:33 pm
Anthonygar
Wed May 29 2024, 03:19 pm
Brandonvab
Wed May 29 2024, 05:35 am
SeymourAdard
Tue May 28 2024, 01:54 pm
DavidAnike
Tue May 28 2024, 08:55 am
BlaineTew
Tue May 28 2024, 06:41 am
Richardesord
Mon May 27 2024, 06:16 pm
Stelota
Mon May 27 2024, 06:03 pm