NC2-51 MCU Learning Board Experimental Program Example 4
[Copy link]
NC2-51 MCU Learning Board Experimental Program Example 51 MCU learning board finished product picture NS-1 download line finished product picture
Programming functions: The NC2-51 single-chip microcomputer learning board has built-in programming function. Go to http://www.nnssh.com/downloads/down3.htm to download the Easy pro isp download line driver. When using, insert the NS-1 (ISP) download cable into the computer parallel port, connect the leads to the learning board (marked on the learning board), turn on the power of the learning board, open the programming program to burn the chip. 4. Sound experiments, such as alarm, song performance, prompt tone, etc.; music output p3.3 pin ORG 0000H LJMP START ORG 000BH INC 20H ; interrupt service, interrupt counter plus 1 MOV TH0,#0D8H MOV TL0,#0EFH ; 12M crystal oscillator, forming a 10 millisecond interrupt RETI START: MOV SP,#50H MOV TH0,#0D8H MOV TL0,#0EFH MOV TMOD,#01H MOV IE,#82H MUSIC0: NOP MOV DPTR,#DAT ; table header address sent to DPTR MOV 20H,#00H ; interrupt counter cleared to 0 MUSIC1: NOP CLR A; ; A cleared MOVC A,@A+DPTR; ; look up the table to get the code JZ END0 ; if it is 00H, then end CJNE A,#0FFH,MUSIC5; ;If it is a rest, execute LJMP MUSIC3 MUSIC5: NOP MOV R6,A; ;R6=18H note frequency INC DPTR; DPTR plus one MOV A,#0 MOVC A,@A+DPTR; ;Get the beat code and send it to R7 MOV R7,A; ;R7=30H note pronunciation time SETB TR0 ;Start counting MUSIC2: NOP CPL p3.2; ;P3.2 is the music output pin MOV A,R6 MOV R3,A; ;R3=R6=18H LCALL DEL MOV A,R7 CJNE A,20H,MUSIC2; ;Is the interrupt counter (20H) = R7? ;If not equal, continue the loop MOV 20H,#00H ;If equal, get the next code INC DPTR LJMP MUSIC1 MUSIC3: NOP ;Pause for 100 milliseconds CLR TR0 MOV R2,#0DH ;R2=13 MUSIC4: NOP MOV R3,#0FFH ;R3=255 LCALL DEL DJNZ R2,MUSIC4 INC DPTR LJMP MUSIC1 END0: NOP MOV R2,#0FFH ;Song ends, delay for 1 second and continue MUSIC6: MOV R3,#00H LCALL DEL DJNZ R2,MUSIC6 LJMP MUSIC0 DEL: NOP DEL3: MOV R4,#02H DEL4: NOP DJNZ R4,DEL4 NOP DJNZ R3,DEL3 RET NOP DAT: DB 18H, 30H, 1CH, 10H DB 20H, 40H, 1CH, 10H DB 18H, 10H, 20H, 10H DB 1CH, 10H, 18H, 40H DB 1CH, 20H, 20H, 20H DB 1CH, 20H, 18H, 20H DB 20H, 80H, 0FFH, 20H DB 30H, 1CH, 10H, 18H DB 20H, 15H, 20H, 1CH DB 20H, 20H, 20H, 26H DB 40H, 20H,20H, 2BH DB 20H, 26H, 20H, 20H DB 20H, 30H, 80H, 0FFH DB 20H, 20H, 1CH, 10H DB 18H , 10H, 20H , 20H DB 26H, 20H , 2BH , 20H DB 30H, 20H , 2BH , 40H DB 20H, 20H , 1CH , 10H DB 18H, 10H, 20H, 20H DB 26H, 20H , 2BH, 20H DB 30H , 20H, 2BH , 40H DB 20H, 30H, 1CH , 10H DB 18H, 20H , 15H , 20H DB 1CH, 20H , 20H , 20H DB 26H, 40H, 20H , 20H DB 2BH, 20H, 26H , 2 0H DB 20H, 20H, 30H, 80H DB 20H , 30H, 1CH, 10H DB 20H, 10H, 1CH, 10H DB 20H, 20H, 26H, 20H DB 2BH, 20H, 30H, 20H DB 2BH, 40H, 20H , 15H DB 1FH, 05H, 20H , 10H DB 1CH, 10H, 20H , 20H DB 26H, 20H, 2BH , 20H DB 30H, 20H, 2BH , 40H DB 20H, 30H, 1CH , 10H DB 18H, 20H , 15H , 20H DB 1CH, 20H , 20H , 20H DB 26H, 40H, 20H , 20H DB 2BH, 20H, 26H , 20H DB 20H, 20H, 30H, 30H DB 20H, 30H, 1CH, 10H DB 18H, 40H, 1CH, 20H DB 20H, 20H, 26H, 40H DB 13H, 60H, 18H , 20H DB 15H, 40H, 13H , 40H DB 18H, 80H, 00H end
|