您现在所在的是:

PLC论坛

回帖:0个,阅读:811 [上一页] [1] [下一页]
905
lansiluo12
文章数:1
年度积分:50
历史总积分:905
注册时间:2006/3/25
发站内信
发表于:2006/3/25 11:52:00
#0楼
用NEC的单片机做,老师说如果是做硬件的,这个问题很简单,一开始都差点没有通过课题,就是因为太简单了,要求就是通过一块NEC的板子控制5个灯的暗亮
给我的程序是3个ASM,我不知道怎么做啊。。。指点。。真的急,这个是MAIN.ASM,还有2个一个是初始化的INIT.ASM还有一个是INT.ASM
;**********************************************************************************
;*                                                        *
;*      AAAA      CCCCCCCCCC  UU       UU  TTTTTTTTTTTT  EEEEEEEEEEE   CCCCCCCCCC *
;*     AA  AA    CCCC      UU       UU       TT       EE      CCCC  *
;*    AAAAAAAA    CCC      UU       UU       TT EEEEEEEEEEE   CCC  *
;*   AA      AA  CCCC      UU       UU       TT EE      CCCC  *
;*  AA        AA  CCCCCCCCCC   UUUUUUUUU        TT EEEEEEEEEEE   CCCCCCCCCC *  
;*                                                        *
;**********************************************************************************
;*  *
;*  User Name : ACUTEC Corporation  *
;*  *
;*  System Name : E-bike congtrol System  *
;*  *
;*  Function : Main module  *
;*  *
;*  CPU : uPD780F500  *
;*  *
;*  Last Update : 2005-6-16 18:15  *
;*  *
;*  File Name : Main.asm  *
;*  *
;* Copyright AcuTec Co. Ltd.  *
;**********************************************************************************

$IC (main.h) ;
;$IC (Init.h) ;



MainCSEG CSEG ;at 0081h
; =================================================================================
;Function Module:main
;Input:
;Output:
;Internal Data:F_2s:18ms Time Flag
;Fuction:(1)LED Light
; (2)Stop mode enter
; =================================================================================
Main:
BT F_Light,$Main00
BT F_KEY,$Main00
STOP

Main00:
CALL !PortCHK
CALL !LedLight ;watchdog counter clr ;STOP mode    
       BR $Main


; =================================================================================
;Function Module:PortCHK
;Input:
;Output:
;Internal Data:
;Fuction:Check key on
; =================================================================================
PortCHK:
CMP T20ms_counter,#0
BNZ $PortCHK_END ;during KEY debouncing
BF F_KEY,$PortCHK_END ;KEY OFF
BT P3.0,$PortCHK_END00

MOV1 CY,F_Light ;led mode set
NOT1 CY
MOV1 F_Light,CY
CALL !REG_init ;initial regist and flag

PortCHK_END00:
CLR1 F_KEY

PortCHK_END:
RET

; =================================================================================
;Function Module:LedLight
;Input:
;Output:
;Internal Data:
;Fuction:LED MD CHECK
; =================================================================================
LedLight:
BF F_Light,$LedLight_END
CMP T1h_counter,#0 ;1 hour timer TEST
BNZ $LedLight00
CLR1 F_Light ;STOP OPERATING
CLR1 F_KEY
BR $LedLight_END

LedLight00:
CMP Led_mode,#_MD1
BZ $LedMD1 ;MD1
CMP Led_mode,#_MD2
BNZ $LedLight10
CALL !LedMD2 ;MD2
BR $LedLight_END00

LedLight10:
CMP Led_mode,#_MD3
BZ $LedMD1 ;MD3
CMP Led_mode,#_MD4
BNZ $LedLight20
CALL !LedMD4 ;MD4
BR $LedLight_END00

LedLight20:
CMP Led_mode,#_MD5
BNZ $LedLight_END
CALL !LedMD5 ;MD5
BR $LedLight_END00

LedLight_END:
CALL !LEDOFF

LedLight_END00:
RET

; =================================================================================
;Function Module:LenMD1/LedMD3
;Input:
;Output:
;Internal Data:
;Fuction:
; =================================================================================
LedMD1:
CMP Led_SEQ,#_LedSeq1
BZ $LedMD1_00
CMP Led_SEQ,#_LedSeq2
BZ $LedMD1_10
CMP Led_SEQ,#_LedSeq3
BZ $LedMD1_20
CMP Led_SEQ,#_LedSeq4
BZ $LedMD1_30
CMP Led_SEQ,#_LedSeq5
BZ $LedMD1_40
CMP Led_SEQ,#_LedSeq6
BZ $LedMD1_50

LedMD1_END:
RET

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led1
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_00:
CALL !LED1

LedMD1_01:
CMP T100ms_counter,#0
BNZ $LedMD1_END
CMP Led_mode,#_MD3
BZ $LedMD1_02
MOV T100ms_counter,#10
BR $LedMD1_03

LedMD1_02:
MOV T100ms_counter,#3

LedMD1_03:
INC Led_SEQ
BR $LedMD1_END

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led2
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_10:
CALL !LED2
BR $LedMD1_01

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led3
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_20:
CALL !LED3
BR $LedMD1_01

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led4
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_30:
CALL !LED4
BR $LedMD1_01

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led5
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_40:
CALL !LED5
CMP T100ms_counter,#0 ;MD1
BNZ $LedMD1_END

CALL !LEDOFF
MOV T1s_counter,#60
MOV Led_SEQ,#_LedSeq6
BR $LedMD1_END

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode1-led6
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD1_50:
CMP T1s_counter,#0
BNZ $LedMD1_END

MOV Led_SEQ,#_LedSeq1
CMP LedCount,#3 ;3 times?
BZ $LedMD1_52
INC LedCount
CMP Led_mode,#_MD3
BZ $LedMD1_51
MOV T100ms_counter,#10
BR $LedMD1_END

LedMD1_51:
MOV T100ms_counter,#3
BR !LedMD1_END

LedMD1_52:
CMP Led_mode,#_MD3
BZ $LedMD1_53
MOV Led_mode,#_MD2 ;Yes,Switch to MD2
MOV T50ms_counter,#5 ;For on/off
MOV T500ms_counter,#10 ;every led on/off time
SET1 F_LED ;Select on first
MOV LedCount,#0
BR $LedMD1_END

LedMD1_53:
MOV Led_mode,#_MD4
MOV T100ms_counter,#10
MOV LedCount,#0
BR $LedMD1_END

; =================================================================================
;Function Module:LenMD2
;Input:
;Output:
;Internal Data:
;Fuction:
; =================================================================================
LedMD2:
CMP Led_SEQ,#_LedSeq1
BZ $LedMD2_00
CMP Led_SEQ,#_LedSeq2
BZ $LedMD2_10
CMP Led_SEQ,#_LedSeq3
BZ $LedMD2_20
CMP Led_SEQ,#_LedSeq4
BZ $LedMD2_30
CMP Led_SEQ,#_LedSeq5
BZ $LedMD2_40

LedMD2_END:
RET

;@@@@@@@@@@@@@@@@
; 500ms check
;@@@@@@@@@@@@@@@@
T500ms_CHK:
CMP T50ms_counter,#0
BNZ $LedMD2_END
MOV T50ms_counter,#5
MOV1 CY,F_LED
NOT1 CY ;on/off switch
MOV1 F_LED,CY
CMP T500ms_counter,#0
BNZ $LedMD2_END
MOV T500ms_counter,#10
INC Led_SEQ
RET

;@@@@@@@@@@@@@@@@
; LED OFF 500ms
;@@@@@@@@@@@@@@@@
LedMD2_OFF:
CALL !LEDOFF
BR $T500ms_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode2-led1
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD2_00:
BF F_LED,$LedMD2_OFF
CALL !LED1
BR $T500ms_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode2-led2
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD2_10:
BF F_LED,$LedMD2_OFF
CALL !LED2
BR $T500ms_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode2-led3
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD2_20:
BF F_LED,$LedMD2_OFF
CALL !LED3
BR $T500ms_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode2-led4
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD2_30:
BF F_LED,$LedMD2_OFF
CALL !LED4
BR $T500ms_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode2-led5
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD2_40:
BF F_LED,$LedMD2_41
CALL !LED5
CALL !T500ms_CHK
BR $LedMD2_42

LedMD2_41:
CALL !LEDOFF
CALL !T500ms_CHK

LedMD2_42:
CMP Led_SEQ,#5
BNZ $LedMD2_END
MOV Led_SEQ,#_LedSeq1
CMP LedCount,#3 ;3 times?
BZ $LedMD2_43
INC LedCount
BR !LedMD2_END

LedMD2_43:
MOV Led_mode,#_MD3 ;Yes,Switch to MD3
MOV T100ms_counter,#10 ;
MOV LedCount,#0
BR $LedMD2_END


; =================================================================================
;Function Module:LenMD4
;Input:
;Output:
;Internal Data:
;Fuction:
; =================================================================================
LedMD4:
CMP Led_SEQ,#_LedSeq1
BZ $LedMD4_00
CMP Led_SEQ,#_LedSeq2
BZ $LedMD4_10
CMP Led_SEQ,#_LedSeq3
BZ $LedMD4_20

LedMD4_END:
RET

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode4-led1
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD4_00:
CALL !LED3

LedMD4_01:
CMP T100ms_counter,#0
BNZ $LedMD4_END ;led3 on for 1s
MOV T100ms_counter,#10
INC Led_SEQ
BR $LedMD4_END

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode4-led2
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD4_10:
CALL !LED24
BR $LedMD4_01

;^^^^^^^^^^^^^^^^^^^^^^^
; Mode4-led3
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD4_20:
CALL !LED15
CMP T100ms_counter,#0
BNZ $LedMD4_END ;led3 on for 1s
MOV T100ms_counter,#10 ;
MOV Led_SEQ,#_LedSeq1
CMP LedCount,#3 ;3 times?
BZ $LedMD4_21
INC LedCount
BR $LedMD4_END

LedMD4_21:
MOV Led_mode,#_MD5 ;Yes,Switch to MD5
;MOV T100ms_counter,#10 ;
MOV T500ms_counter,#50
SET1 F_LED ;Select on first
MOV LedCount,#0
MOV LedCount0,#0
BR $LedMD4_END


; =================================================================================
;Function Module:LenMD5
;Input:
;Output:
;Internal Data:
;Fuction:
; =================================================================================
LedMD5:
CMP Led_SEQ,#_LedSeq1
BZ $LedMD5_00
CMP Led_SEQ,#_LedSeq2
BZ $LedMD5_10

LedMD5_END:
RET

;@@@@@@@@@@@@@@@@
; 1s check
;@@@@@@@@@@@@@@@@
T1s_CHK:
CMP T100ms_counter,#0
BNZ $LedMD5_END
INC LedCount0
CMP LedCount0,#3
BZ $T1s_CHK00
MOV T100ms_counter,#10
MOV1 CY,F_LED
NOT1 CY ;on/off switch
MOV1 F_LED,CY
BR $T1s_CHK_END

T1s_CHK00:
INC Led_SEQ
MOV LedCount0,#0
MOV T500ms_counter,#50

T1s_CHK_END:
RET

;@@@@@@@@@@@@@@@@
; LED OFF 1s
;@@@@@@@@@@@@@@@@
LedMD5_OFF:
CALL !LEDOFF
BR $T1s_CHK


;^^^^^^^^^^^^^^^^^^^^^^^
;  Mode5-led all on/off
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD5_00:
BF F_LED,$LedMD5_OFF
CALL !LEDON
BR $T1s_CHK

;^^^^^^^^^^^^^^^^^^^^^^^
;   Mode5-led all off
;^^^^^^^^^^^^^^^^^^^^^^^
LedMD5_10:
CALL !LEDOFF
CMP T500ms_counter,#0
BNZ $LedMD5_END
MOV Led_SEQ,#_LedSeq1
CMP LedCount,#3
BZ $LedMD5_11
INC LedCount
MOV T100ms_counter,#10
SET1 F_LED
BR $LedMD5_END

LedMD5_11: ;Switch to MD1
MOV Led_mode,#_MD1 ;
MOV T100ms_counter,#10 ;
MOV LedCount,#0
MOV LedCount0,#0
BR $LedMD5_END


; =================================================================================
;Function Module:Led light control
;Input:
;Output:
;Internal Data:
;Fuction:
; =================================================================================
LED1:
CLR1 P6.0 ;led1 on;others off
SET1 P6.1
MOV P0,#00000011B
SET1 P12.0
RET

LED2:
MOV P6,#00000011B ;led2 on;others off
CLR1 P0.0
SET1 P0.1
SET1 P12.0
RET

LED3:
MOV P6,#00000011B ;led3 on;others off
MOV P0,#00000011B
CLR1 P12.0
RET

LED4:
MOV P6,#00000011B ;led4 on;others off
CLR1 P0.1
SET1 P0.0
SET1 P12.0
RET

LED5:
CLR1 P6.1 ;led5 on;others off
SET1 P6.0
MOV P0,#00000011B
SET1 P12.0
RET

LED15: ;led1 and led5 on;others off
MOV P6,#00000000B
MOV P0,#00000011B
SET1 P12.0
RET

LED24:
MOV P6,#00000011B ;led2 and led4 on;others off
MOV P0,#00000000B
SET1 P12.0
RET

LEDON:
MOV P6,#00000000B ;all off
MOV P0,#00000000B
CLR1 P12.0
RET

LEDOFF:
MOV P6,#00000011B ;all off
MOV P0,#00000011B
SET1 P12.0
RET





END

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 非法和不良信息举报

工控网客服热线:0755-86369299
版权所有 工控网 Copyright©2024 Gkong.com, All Rights Reserved

62.4004