找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

利用数码管显示0-199计数 程序下载到板子上百位显示不正常

[复制链接]
huster 发表于 2014-11-8 15:23:36 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×

          ;------------------------------------
;-  Generated Initialization File  --
;------------------------------------

$include (C8051F310.h)

public  Init_Device
ORG 0000H
GEIWEI EQU 60H
SHIWEI EQU 70H
BAIWEI EQU 80H
LJMP MAIN

  ORG 0100H
MAIN:
LCALL Init_Device
MOV R2,#00
LOOP:
MOV A,R2
MOV B,#10
DIV AB
MOV GEIWEI,B
MOV B,#10
DIV AB
MOV SHIWEI,B
MOV B,#10
DIV AB
MOV BAIWEI,B
MOV A,BAIWEI
  MOV DPTR,#TAB
MOVC A,@A+DPTR
  MOV P1,A
CLR P0.6
CLR P0.7
   
LCALL DELAY
   MOV A,SHIWEI
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P1,A
  SETB P0.6
CLR P0.7
LCALL DELAY
MOV A,GEIWEI
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P1,A
  CLR P0.6
SETB P0.7

LCALL DELAY
  INC R2
   SJMP LOOP
   
   TAB: DB 0FCH,060H,0DAH    ; 段码数据表
       DB 0F2H,066H,0B6H
           DB 0BEH,0E0H,0FEH,0F6H
        DELAY:
        MOV R3,#10
     D3: MOV R0,#200
    D1: MOV R1,#200
     D2: DJNZ R1,D2
     DJNZ R0,D1
         DJNZ R3,D3
      RET

INIT SEGMENT CODE
    rseg INIT

; Peripheral specific initialization functions,
; Called from the Init_Device label
PCA_Init:
    anl  PCA0MD,    #0BFh
    mov  PCA0MD,    #000h
    ret

Timer_Init:
    mov  TMOD,      #010h
    mov  CKCON,     #002h
    ret

Port_IO_Init:
    ; P0.0  -  T1 (Timr1),  Open-Drain, Digital
    ; P0.1  -  Unassigned,  Open-Drain, Digital
    ; P0.2  -  Unassigned,  Open-Drain, Digital
    ; P0.3  -  Unassigned,  Open-Drain, Digital
    ; P0.4  -  Unassigned,  Open-Drain, Digital
    ; P0.5  -  Unassigned,  Open-Drain, Digital
    ; P0.6  -  Skipped,     Open-Drain, Digital
    ; P0.7  -  Skipped,     Open-Drain, Digital

    ; P1.0  -  Skipped,     Open-Drain, Digital
    ; P1.1  -  Skipped,     Open-Drain, Digital
    ; P1.2  -  Skipped,     Open-Drain, Digital
    ; P1.3  -  Skipped,     Open-Drain, Digital
    ; P1.4  -  Skipped,     Open-Drain, Digital
    ; P1.5  -  Skipped,     Open-Drain, Digital
    ; P1.6  -  Skipped,     Open-Drain, Digital
    ; P1.7  -  Skipped,     Open-Drain, Digital
    ; P2.0  -  Unassigned,  Open-Drain, Digital
    ; P2.1  -  Unassigned,  Open-Drain, Digital
    ; P2.2  -  Unassigned,  Open-Drain, Digital
    ; P2.3  -  Unassigned,  Open-Drain, Digital

    mov  P0SKIP,    #0C0h
    mov  P1SKIP,    #0FFh
    mov  XBR1,      #060h
    ret

; Initialization function for device,
; Call Init_Device from your main program
Init_Device:
    lcall PCA_Init
    lcall Timer_Init
    lcall Port_IO_Init
    ret

end
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-23 10:58 , Processed in 0.050821 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表