1 introduction
The institution, the colleges and universities daily work and rest needed to time and the bugle call prompt, the author constituted the automatic time and the bugle call player using at89C51 monolithic integrated circuit and the LM386 audio power amplifier, the cost are low, the effect was good, is worth promoting.
2 AT89C51 principal characteristics and pin function
AT89C51 has the 4K byte glitters programmable may clean the non-erasable storage (EPEROM) the low voltage, the high performance CMOS 8 microprocessors (to be named monolithic integrated circuit). This monolithic integrated circuit and industrial standard’s MCS-51 molding machine’s set of instructions and the output pin is compatible. AT89C51 multi-purpose 8 CPU and the twinkle memory combination in the single chip, will provide the flexibility for the embedded control to be high, and low in price plan.
At89C51 principal characteristic is as follows:
The life reaches 1000 writes/scratches the circulation;
Retention of data time: 10 years;
Entire quiescent operation: 0Hz-24MHz;
Third-level program memory locking;
128×8 position interior RAM;
32 programmable I/O lines;
2 16 timer/counters;
5 interrupt sources;
Programmable serial channel;
Low power loss idle and power failure pattern;
Internal oscillator and clock circuit.
AT89C51 pin arrangement as shown in Figure 1, the pin function is as follows:
![]() |
|---|
VCC (40): 5V.
GND (20): Earth.
P0 mouth (39-32): The P0 mouth is 8 drain electrode opening bidirectional I/O mouth, each pin may absorb 8 TTL gate electric current.
P1 mouth (1-8): The P1 mouth is provides on pulls resistor’s 8 bidirectional I/O mouth from the interior, the P1 mouth buffer can receive and output 4 TTL gate electric current.
P2 mouth (21-28): The P2 mouth pulls resistor’s 8 bidirectional I/O mouth for the interior, the P2 mouth buffer may receive and output 4 TTL gate electric current.
P3 mouth (10-17): The P3 mouth is in 8 belt interior pulls resistor’s bidirectional I/O mouth, may receive and output 4 TTL gate electric current, the P3 mouth may also take AT89C51 the special function mouth.
RST (9): Reset input. When the oscillator repositions, must maintain the RST pin 2 machine cycles the high level time.
ALE/PROG (30): When visits the exterior memory, the address lock saves the permission the power output to use in the lock saving the address the low byte, in FLASH programming period, this pin uses in inputting the programming pulse. In usually, the ALE end outputs the signal impulse by the invariable frequency period, this frequency for the oscillator frequency 1/6, it available opposes the exterior output the pulse or uses in fixed time the goal, what must pay attention, when visits the exterior data-carrier storage, will jump over 1 ALE pulse.
PSEN (29): Exterior program memory’s gating signal. In takes by the exterior program memory refers to the period, each machine cycle 2 PSEN is effective, but when visits the exterior data-carrier storage, these 2 effective PSEN signal will not appear.
EA/VPP (31): When EA maintains the low level, exterior program memory address for (0000H-FFFFH), no matter whether to have the internal procedure memory. FLASH programming period, this pin also uses in exerting the 12V programming power source (VPP).
XTAL1 (19): Reverse oscillator amplifier’s input and internal clock active channel’s input.
XTAL2 (18): From reverse oscillator’s output.
3 bugle call automatic broadcast system’s design
Bugle call automatic broadcast system as shown in Figure 2, AT89C51 P1.0 termination audio frequency amplification module IN port, in audio frequency amplification module VOUT termination one 8 ohms or 16 ohm loudspeaker.
3.1 circuit designs and music programming principle
If produces the audio frequency pulse, so long as figures out some audio frequency the cycle (1/frequency), divides again this cycle 2, namely for alternation time. Using timer time alternation time, whenever after timing terminates, the P1.0 opposition, then redundant time again opposition. May obtain this frequency pulse on the P1.0 pin.
Causes its work counter pattern using at89C51 internal timer (MODE1), change counting value TH0 and TL0 have the different frequency method to have the different scale, for example, the frequency is 523Hz, its cycle T=1/523=1912μs, when therefore make the counter time 956μs/1μs=956, counts every time 956 times the I/O opposition, may obtain tenor DO (523Hz).
![]() |
|---|
The counter impulse value and the frequency relationship is:
N=fi÷2÷fr
In the formula, N is the counting value; (when fi is the machine frequency crystal oscillator is 12MHz, its frequency is 1MHz); fr is the frequency which the wish produces.
Its counting starting value T asks the law to be as follows:
T=65536-N=65536-fi÷2÷fr
For example: Supposes K=65536, fi=1MHz, asks bass DO (261Hz), tenor DO (523Hz), treble DO (1046Hz) counting value.
T=65536-N=65536-fi÷2÷fr=65536-1000000÷2÷fr=65536-500000/fr
Bass DO T=65536-500000/262=63627
Tenor DO T=65536-500000/523=64580
Treble DO T=65536-500000/1046=65059
C adjusts various notes frequency and counting starting value T comparison as shown in Table 1.
![]() |
|---|
3.2 master routine flows
This system mainly completes the work and rest fixed time with the bugle call broadcast function, therefore has the 100ms reference time with the timer T1 interrupt mode, each period of time’s length times again according to the work schedule to the reference time with the software. May use the table look-up way to obtain the counting parameter, after timing, will broadcast the subroutine address to deliver DPTR, changes over to the broadcast subroutine, after putting 2 corresponding bugle call, continues to time again. Master routine flow as shown in Figure 3.
![]() |
|---|
The broadcast subroutine is controls P1.0 with the T0 interrupt mode to take unceasingly counter-has the different frequency note, the metre length depending on transfers the 200ms time delay subroutine number of times to complete. The subroutine also uses the table look-up to complete.



