4200 views|0 replies

1379

Posts

0

Resources
The OP
 

NC2-51 MCU Learning Board Experimental Program Example 3 [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.


3. 3-key control experiment, such as data adjustment, function conversion, etc
.; Electronic spreadsheet program example
; K1 adjusts the hour +1
; K2 adjusts the minute +1
; The LED indicator light of P1.1 pin flashes once every second
; ==========================
;
a_bit equ 20h; The units digit of the digital tube is stored in the memory location
b_bit equ 21h; The tens digit of the digital tube is stored in the memory location
c_bit equ 22h; The hundreds digit of the digital tube is stored in the memory location
d_bit equ 23h; The thousands digit is stored in the memory location;

ORG 00H
AJMP MAIN
ORG 0BH
AJMP TIMED
ORG 30H

MAIN:MOV SP,#60H
MOV P0,#0FFH
MOV P2,#0FFH
MOV P3,#0FFH
MOV R0,#20H
MOV R7,#7H
TIME:MOV @R0,#00
INC R0
DJNZ R7,TIME
;*************************初始化
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB EA
SETB ET0
SETB TR0

TIME1:
ACALL DISP
MOV A,R1
CJNE A,#20,L1
MOV R1,#0
CPL P1.1
;CPL P3.2;
INC R2
L1: MOV A,R2
CJNE A,#60,L2
MOV R2 ,#0
INC 24H
L2: MOV A,24H
SUBB A,#60
JNZ L3
MOV 24H,#0H
INC 25H
L3: MOV A,25H
SUBB A,#12
JNZ L4
MOV 25H,#0H
;******; ***************************
L4:
MOV A,24H
MOV B,#10
DIV AB
MOV A_BIT,B
MOV B_BIT,A
MOV A ,25H
MOV B,#10
DIV AB
MOV C_BIT,B
MOV D_BIT,A
AJMP TIME1
RET
;***************************** **
TIMED:PUSH PSW
PUSH ACC
MOV TH0,#3CH
MOV TL0,#0B0H
INC R1
POP ACC
POP PSW
RETI

;******************************************Display subroutine
DISP:mov dptr,#numtab;Specify the start address of the table lookup

mov a,a_bit ;get the unit digit
MOVC A,@A+DPTR ;check the 7-segment code of the unit digit
mov p0,a ;send the 7-segment code of the unit digit
clr p2.6 ;turn on the unit digit display
ACALL DELY1 ;display for 1 millisecond
setb p2.6 ;turn off the unit digit display to prevent ghosting

mov a,b_bit; get the ten-digit number
MOVC A,@A+DPTR; check the code
mov p0,a; send out 7-segment code
clr p2.5; turn on the display
ACALL DELY1; display for 1 millisecond
setb p2.5; turn off the display to prevent ghosting

mov a,c_bit; get the hundreds digit
MOVC A,@A+DPTR; check the code
mov p0,a; send 7-segment code
clr p2.4; turn on the display
ACALL DELY1; display for 1 millisecond
setb p2.4; turn off the display to prevent ghosting

mov a,D_bit ;get thousands digit
MOVC A,@A+DPTR ;check code
mov p0,a ;send 7-segment code
clr p2.3 ;turn on display
ACALL DELY1;display for 1 ms
setb p2.3;turn off display to prevent ghosting
;********************************
C1:JB P3.3,C2
ACALL DELAY10;delay 10 ms to eliminate jitter
JB P3.3,C1
JNB P3.3,$;wait for button to be released
INC 25H
AJMP C5
C2:JB P3.6,C3
ACALL DELAY10;delay 10 ms to eliminate jitter
JB P3.6,C2
JNB P3.6,$;wait for button to be released
INC 24H
AJMP C5
C3:JB P3.7,C5
ACALL DELAY10
JB P3.7,C3
JNB P3.7,$
INC 27H
AJMP C5
;C4:JB P2.6,C5
; ACALL DELAY10
; JB P2.6,C4
; JB P2.6,$
; INC 26H
C5:
ret
;***************************************
;1ms delay subroutine
DELY1: MOV R4,#2
D1: MOV R5,#248
DJNZ R5,$
DJNZ R4,D1
RET
;10ms delay subroutine
DELAY10:MOV R4,#20
D2: MOV R5,#248
DJNZ R5,$
DJNZ R4,D2
RET

; The common cathode display code of the 7-segment digital tube 0 to 9 on the experimental board
numtab:DB 0EBH,00AH,067H,06EH,08EH,0ECH,0EDH,02AH,0EFH,0EEH

END

This post is from 51mcu
 

Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list