Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 Double pulse generator

Status
Not open for further replies.

98Altima

Newbie level 2
Joined
Jul 5, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
I am trying to generate a double pulse, say 2us long @ 500hz, only twice every 2 periods... to get an average of 250hz.

___|_|___|_|___|_|___|_|___

Any one have any good ideas on where to start? I am fairly new to programming but cant definitly find my way around. I have a project in need of this input, and instead of ordering some expensive signal generator way out of my price range im trying to accomplish this with a C8051FX20 dev kit.

Thanks for all replies!
 

The easy way is to use delay(s), more advanced (and more accurate) solution will involve timers and interrupts ..
So, just to give you something to start with, here is an example of the first approach:
Code:
…
	CLR	P1.X		; X is your output pin
…

	MOV	B, #0FFh
	DJNZ	B, $		; 256 cycles delay, time will depend on your clock ..
				; this can be repeat as many times as necessary ..
Loop1:
	SET	P1.X
	NOP			; SET and NOP give you 2 cycles delay,
	…			; add as many NOPs as required for 2us ..
	CLR	P1.X

	MOV	B, #0FFh
	DJNZ	B, $		; 256 cycles delay, time will depend on your clock ..
	…			; this can be repeated as many times as necessary ..
	MOV	B, #0FFh
	DJNZ, B, $

	SET	P1.X
	NOP			; SET and NOP give you 2 cycles delay,
	…			; add as many NOPs as required for 2us ..
	CLR	P1.X

	MOV	B, #0FFh
	DJNZ	B, $		; 256 cycles delay, time will depend on your clock ..
	…			; this can be repeated as many times as necessary ..
	MOV	B, #0FFh
	DJNZ, B, $

SJMP loop1

:wink:
IanP
 

Should have stated most my experience is in C :-?

Very much appreciate the example though, i figured as much with interrupts and timers. just wanted some validation from someone.

I'll give this a shot tomorow, thanks much IanP
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top