NC2-51 MCU Learning Board Experimental Program Example 2
[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.
2. 4-bit common negative digital experiment, such as counting, data display, etc. a_bit equ 20h; thousands digit b_bit equ 21h; hundreds digit c_bit equ 22h; tens digit d_bit equ 23h; ones digit temp equ 24h; counter value storage location temp1 equ 25h star: mov temp,#0 ; Initialize, start from 0 mov temp1,#0 stlop: acall display; Call display subroutine inc temp; Add 1 to counter mov a,temp cjne a,#100,next ; Check if it is full 100 mov temp,#0 inc temp1 mov a,temp1 cjne a,#60,next mov temp1,#0; Clear 0 ;mov temp,#0; next: ljmp stlop; Loop if not full ;Display subroutine display: mov a,temp ;Convert the hexadecimal number in temp to decimal mov b,#10 ;10/10=decimal div ab mov b_bit,a ;The tens digit is in a mov a_bit,b ;The ones digit is in b mov a,temp1 mov b,#10 div ab mov c_bit,a ;The thousands digit is in c mov d_bit,b ;The hundreds digit is in d mov dptr,#numtab ;specify table address ;mov r0,#2;4 dpl1: mov r1,#50;250 ; dplop: mov a,a_bit ;get unit digitMOVC A,@A+DPTR ;look up the 7-segment code of unit digitmov p0,a ;send out the 7-segment code of unit digitclr p2.6 ;turn on unit digit displayacall d1ms ;call delay setb p2.6;turn off displaymov a,b_bit ; MOVC A,@A+DPTR ; mov p0,a ; clr p2.5; acall d1ms ; setb p2.5 mov a,d_bit ; MOVC A,@A+DPTR ; mov p0,a ; clr p2.4 acall d1ms setb p2.4 mov a,c_bit MOVC A,@A+DPTR mov p0,a clr p2.3; acall d1ms; setb p2.3 djnz r1,dplop; ;djnz r0,dpl1 ret ;2+2X80=162 microseconds delay, calculated at 12MHZ frequency D1MS: MOV R7,#80 DJNZ R7,$ RET ;The 7-segment digital tube 0~9 digits on the experimental board display code numtab:DB 0EBH,00AH,067H,06EH,08EH,0ECH,0EDH,02AH,0EFH,0EEH end
|