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.

[51] how to generate two or more timing signals (square) AT89S52

Status
Not open for further replies.
In contrast to modern microcontrollers, AT89S52 has no hardware timer outputs. So the timing signals have to be generated in software, e.g. in a timer interrupt. A detailed specification can show if it's feasible with sufficient accuracy.
 
@Anand...

As @FvM said, due to the lack of proper external timers, you have to rely on software, thus consuming the processor. However AT89S52 datasheet shows that clock generated from its internal timer 2 can be passed to P1.0. Thus saving the main processor from burden. So there is a chance of running two independent clocks, one by RCAP2H&L, and another by simply calculating delays or using another timer.
Refer to atmel AT89S52 datasheet, "Programmable Clock Out"...
 

    V

    Points: 2
    Helpful Answer Positive Rating
You can find all the help from the datasheet, or you can google search for setting timer 2 as clock out... I haven't used 89S52 yet, but if I had to program timer 2, according to the datasheet, I would write [in ASM]:

Code:
; Configure Timer 2 as Clock Out
CLR T2CON.1
SETB T2MOD.1

; Load Clock values [Crystal : 12MHz, Clock Out : 3MHz]
MOV RCAP2H, #0FFH
MOV RCAP2L, #0FFH

; Start Timer 2, output clock at P1.0
SETB T2CON.2

; Configure Timer 0 as 16 bit timer
MOV TMOD, #01H

Reload:
; load Clock values [Crystal : 12MHz, Clock Out : 1kHz]
MOV TH0, #0FCH
MOV TL0, #018H

; Start Timer 0, output clock at P1.1
SETB TR0
CPL P1.1

; Check for overload
JNB TF0, $
CLR TF0
JMP Reload

You can give it a try to see how it works. You can change clock values according to your need.
 

Its not mentioned in datasheet that the timer reloads itself. But its understood that timer 2 with given T2CON & T2MOD configuration will work independently, as this configuration of timer 2 is also used for baud rate generation. So only bit you need to be concerned of is the TR2 (Timer 2 start/stop) bit.
If you have a piece of that mcu, you can give it a try to see if it works. I don't have this chip, so I cannot test it for you...


Note: Timers are independent piece of hardware which doesn't consumes processor. However, they are interfaced with the main processor and can work either independently or coordinately. So restarting the timers is not always compulsory if the given timer has the feature... ;-)
 


Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top