1 introduction
Based on the RTX51 music edition generator take at89S52 monolithic integrated circuit as the control core, the operator may through 4×4 the matrix keyboard input agreement form random music, after “broadcast” key, the system then starts the music which broadcasts edits, and the tonality and the metre may by the monolithic integrated circuit accuracy control. In order to reduce the cost, in the smallest hardware design’s foundation, system’s function uses the software to realize as far as possible, the system software is in faces MCS-51 in the series monolithic integrated circuit’s embedded real-time multi-duty operating system RTX51Tiny platform, develops with the C51 higher order language and the MCS-51 assembly language mix programming.
2 system hardware designs
For the present can the online promotion user application procedure, use brings ISP connection monolithic integrated circuit AT89S52 is the core constitution music edition generator. AT89S52 has the fast 8051 essences, 8 KB FlashE2PROM, 256 B IDATA RAM, tallies completely moves the RTX51Tiny hardware request. The author has developed at89S51/52 target program PC machine downloading software, does not need the programmer then to complete the monolithic integrated circuit application system’s development.
In order to design the edition random music the man-machine contact surface, uses 4×4 the matrix keyboard to take system’s input device, uses lattice type liquid crystal display module TC1602A to take system’s output unit. In order to save and read out the random music, uses brings I2C serial interface E2PROM memory AT24C02. In order to enlarge the music sound which monolithic integrated circuit AT89S52 produces, has used power amplifier LM386. System hardware electric circuit schematic diagram as shown in Figure 1.

3 music editions and the broadcast software realizes
3.1 monolithic integrated circuits have the audio frequency square pulse method
And causes its work using monolithic integrated circuit’s internal timer T1 at the timer working 1 (16 bit fixed time), changes T1 the counting starting value, may produce the different frequency audio frequency square pulse in monolithic integrated circuit’s I/O pin end.
For example, the audio frequency square pulse signal’s frequency is 523 Hz, then its cycle T=1/523=1912μs, therefore, so long as lets the counter fixed time 1912μs÷2=956μs, when fixed time 956μs arrives time, at89S52 music output pin P3.7 opposition, may obtain tenor DO (523 Hz).
Monolithic integrated circuit timer counting starting value T and monolithic integrated circuit interior machine cycle signaling frequency Fi and the audio frequency square pulse signaling frequency Fr relations are as follows.
![]()
For clearer expression, might as well is called timer counting starting value T the numbered musical notation code.
3.2 music tonality expression methods
The monolithic integrated circuit broadcast music’s process, is mainly the music which distinguishes with the monolithic integrated circuit edits and broadcasts. The monolithic integrated circuit needs to distinguish in the music the tonality and the length (length is also called metre), this design represents the music with letter A~Z each tonality. The digit 0 took the tonality the end mark, as shown in Table 1.

3.3 music edition’s software realizes the method
When the system software designs, will have pressed a key processing to take a duty namely “the pressed key processing duty”, its major function edits the music. “pressed key processing duty” the execution need “the keyboard scanning duty” triggers the execution to its sending signal. “pressed key processing duty” the C51 source program is as follows.



3.4 music broadcast’s software realizes the method
When design “broadcast duty” procedure, fixed time overflow trap has the tonality frequency using AT89S52 the internal timer T1, and produces the length using the RTX51 operating system’s os_wait2(K_TMO, ticks) function. “broadcast duty” the C51 source program is as follows:


3.5 system software flows
According to system function’s analysis, the system software decomposition is 5 duties, is specifically as follows:
Duty 0: System initialization duty, including TC1602A initialization, timer T1 initialization, interrupt initialization. After initiating task 1~ duties 4, deletes the duty automatically 0, causes duty 0 when the system the electricity replacement carries out one time.
Duty 1: Keyboard scanning duty. Every other 50 ms carries out 1 time, scans the obtained key value to save in global variable keycode, then approaches “the pressed key processing duty” the sending a letter number.
Duty 2: Pressed key processing duty. The waiting signal, completes corresponding processing according to key value keycode, realizes function including music edition, music preservation and read and so on.
Duty 3: Broadcast duty. Waiting signal, according to tonality and length broadcast music.
Duty 4: Demonstration refurbishing duty. Demonstrates the music data according to the cursor pointer variable’s value in the liquid crystal box (tonality and length).
System software flow chart as shown in Figure 2.

4 concluding remark
This article has given take monolithic integrated circuit AT89S52 as the core constitution random music edition generator, has the hardware circuit to be simple, the operation contact surface is friendly, easy to operate characteristic. This system put the operation, broadcasts the music effect is good, the tonality and the metre control by the monolithic integrated circuit quite accurately.