Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

[MOVED] 8051 generating two square waves simultaneously

Status
Not open for further replies.

carismine

Newbie level 1
Joined
Dec 12, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
I need to generate 10khz and 1khz square waces at P1.0 and P1.4 simultaneously
Clock = 1MHz
Am i on the right track?
1/10k = 100us -> timer0 mode2
1/1k = 1000us -> timer1 mode1

mov tmod, #12H; setting up timers
mov th0, #0CEH; -50cycles for timer 0 mode 2
setb tr0; start timer 0
setb tr1; start timer 1
mov ie,#8AH; setting interrupt enable register

this is where i'm stuck. do i/can i set two different waits for two different interrupts
or do i just put a wait (wt:sjmp wt) in and include it all in one interrupt? and set a count like it takes 10 interrupts of timer 0 (100us) to get 1 interrupt of timer 1 (1000us) so in the ISR code i'd put somehting like

interrupt code for timer (100us)
DJNZ R7, EXT; where R7 = 0AH
interrupt code for timer (1000us)
EXT: RETI

thanks for all the help in advance
 
Last edited:

rohitkhanna

Banned
Joined
May 1, 2012
Messages
341
Helped
76
Reputation
150
Reaction score
75
Trophy points
1,308
Location
New Delhi, India
Activity points
0
Or you could do it with just one timer set for 50uS and a single interrupt. Toggle the 10KHz line everytime
For 1KHz, count 10 and only then toggle the 1KHz line.

Should be easier to manage.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top