⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shutter_ctrol.asm

📁 Function:1、摄像头快门速度控制。 2、闪光灯控制。 性能参数: 1、摄像头快门速度:1us - 20ms 2、闪光灯位置:可设置在一场的任意时刻。 3、快门可工作在自动方式。
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;-------------------------------------------------------------------------------
; Copyright 2002/06/27-2005/06/27 Shanghai Goldway ITS Co. Ltd                 *
; All right reserved.                                                          *
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
;*
;* Project   : Camera Shutter Control
;* Module    : Camera Shutter Control
;* File name : PR9325.asm
;* Author(s) : Wei Penghui
;* Creation Date: 2003/02/20
;* PS		    : indent = 4 spaces, NO tab's allowed!
;* Description  : 牌照识别器摄像头控制程序,Control the shutter speed
;*
;-------------------------------------------------------------------------------
;			CPU Frequency	: 7.09375MHz
;			RS232 Set	: 8 Bits, No Parity, 1 Stops, 9600
;
;			Function:	1、摄像头快门速度控制。
;					2、闪光灯控制。
;			性能参数:	1、摄像头快门速度:1us - 20ms
;					2、闪光灯位置:可设置在一场的任意时刻。
;					3、快门可工作在自动方式。
;  Data type prefix
;  b        bit
;  uch      unsigned byte
;  ch       signed byte
;  w        word(2 bytes)
;  dw       double word(4 bytes)
;  a        array
;
;-------------------------------------------------------------------------------
;*
;* Modification history
;*
;* Date          Revision    By           Comment
;* 2004/07/19    0x1        Song Zhenyu    can write to flash
;* 2004/08/05    0x2        Song Zhenyu    Add heaader
;-------------------------------------------------------------------------------
$INCLUDE(MOD932)
$TITLE(Camera Shutter Control)
$DATE(18/6/2003)
$DEBUG
$OBJECT
$NOPAGING

;-------------------------------------------------------------------------------
; Signal define.
bXV2        BIT     P2.3    ; Horizontal transfer pulse(Positive pulse)
_bXV3       BIT     P1.4    ; Horizontal transfer pulse(Negative pulse)
_bXSG1      BIT     P1.3    ; CCD readout pulse(Negative pulse)
_bXSubIn    BIT     P0.7    ; Auto discharge pulse.
_bXSubInB   BIT     P0.4    ; Alternative "nXSub_In"
_bXSubOut   BIT     P0.6    ; Discharge pulse(Negative pulse)
bFlashA     BIT     P2.0    ; Photoflash A control pin
bFlashB     BIT     P2.1    ; Photoflash B control pin
_bRxd       BIT     P1.1    ; UART Receive port
bAuto_En    BIT	    P0.0    ; the AutoG mode control

;ISP Code entry
Isp_Entry   CODE    01E00H
Pgm_Mtp     CODE    0FF00H
;-------------------------------------------------------------------------------
; Data Segment. (All datas are in little endian)
                DSEG  AT 30H
uchSysCtl:      DS      1

wNsSpd:         DS      2
uchNsSpdExt:    DS      1
wFsSpd:         DS      2
uchFsSpdExt:    DS      1
uchFlashAPos:   DS      1

uchFlashBPos:   DS      1

uchPreFlashA:   DS      1
uchPreFlashB:   DS      1
uchPreFlash:    DS      1
uchFieldCnt:    DS      1
wRowCnt:        DS      2
uchRowCntExt:   DS      1
uchFlashCnt:    DS      1

uchSumCheck:    DS      1
aUartRcvBuf:    DS      10

                BSEG    AT 00H
bUARTRcvValid:  DBIT    1
bFlashAEnable:  DBIT    1
bFlashBEnable:  DBIT    1
bSampleA:       DBIT    1
bSampleB:       DBIT    1
bSampleC:       DBIT    1
bIsCapture:     DBIT    1
bClrDogEnable:  DBIT    1
bAutoCtlEnable:	DBIT	1
;-------------------------------------------------------------------------------
; Code Segment.
            CSEG                    ;Set code segment acive.
            ORG     0000H
RESET:      LJMP    MAIN            ; Main program entry point.
            LJMP    Isr_Ex0         ; 0003H (External interrupt 0)
            NOP
            NOP
            LJMP    ERR             ; Software trap.
            LJMP    ERR             ; 000BH (Timer 0 interrupt)
            NOP
            NOP
            LJMP    ERR             ; Software trap.
            LJMP    Isr_Ex1         ; 0013H (External Interrupt 1)
            NOP
            NOP
            LJMP    ERR             ; Software trap.
            LJMP    ERR             ; 001BH (Timer 1 Interrupt)
            NOP
            NOP
            LJMP    ERR             ; Software trap.
            LJMP    ERR             ; 0023H (RS232 RI or RI&TI Interrupt)
            NOP
            NOP
            LJMP    ERR             ; Software trap
            LJMP    ERR             ; 002BH (Brownout Detect Interrupt)
            NOP                     ; (Used only in P89LPC932)
            NOP
            LJMP    ERR
            LJMP    ERR             ; 0033H (I2C Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 003BH (KBI Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 0043H (Cmp1/2 Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 004BH (SPI Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 0053H (Watchdog or RTC Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 005BH (CCU Interrupt)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 0063H (Reserved)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 006BH (RS232 TI)
            NOP
            NOP
            LJMP    ERR
            LJMP    ERR             ; 0073H (EEPROM Write Completed Interrupt)
ERR:        LJMP    RESET           ; Software trap.

MAIN:       MOV     SP, #7FH
            LCALL   Init_UART
            LCALL   Init_Interrupt
            LCALL   Init_Port
            LCALL   Init_DSEG
            CLR     TI
            MOV     SBUF, #0A5H
            JNB     TI, $
            CLR     TI
            MOV     SBUF, #05AH
            JNB     TI, $
            CLR     TI
            MOV     PCONA, #0EDH


            SETB    EX0
            SETB    EA
            LCALL   Init_WD
            LCALL   WaitForCapture
; Receive command from the host
M_L01:      LCALL   ReceiveOneByte
            CJNE    A, #055H, M_L01
            LCALL   ReceiveOneByte
            CJNE    A, #0AAH, M_L01
            LCALL   ReceiveOneByte
            MOV     uchSumCheck, A
            MOV     aUartRcvBuf, A
            ANL     A, #0F0H
            JNZ     M_L01
            MOV     DPTR, #M_TBL0
            MOV     A, aUartRcvBuf
            RL      A
            JMP     @A+DPTR
M_TBL0:     AJMP    M_Cmd_0
            AJMP    M_Cmd_1
            AJMP    M_Cmd_2
            AJMP    M_Cmd_3
            AJMP    M_Cmd_4
            AJMP    M_Cmd_5
            AJMP    M_Cmd_6
            AJMP    M_Cmd_7
            AJMP    M_Cmd_8
            AJMP    M_Cmd_9
            AJMP    M_Cmd_A
            AJMP    M_Cmd_B
            AJMP    M_Cmd_C
            AJMP    M_Cmd_D
            AJMP    M_Cmd_E
            AJMP    M_Cmd_F

M_Cmd_0:    AJMP    M_L01

; EX0_Cmd_1 (Change the fast shutter speed)
M_Cmd_1:    LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+1, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+2, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+3, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+4, A
            LCALL   ReceiveOneByte
            MOV     aUartRcvBuf+5, A
            LCALL   ReceiveOneByte
;            CJNE    A, uchSumCheck, MC1_L05
            SETB    bUARTRcvValid
MC1_L05:    AJMP    M_L01

; EX0_Cmd_2 (Change the nature shutter speed)
M_Cmd_2:    LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+1, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+2, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+3, A
            LCALL   ReceiveOneByte
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+4, A
            LCALL   ReceiveOneByte
            MOV     aUartRcvBuf+5, A
            LCALL   ReceiveOneByte
;            CJNE    A, uchSumCheck, MC2_L05
            SETB    bUARTRcvValid
MC2_L05:    AJMP    M_L01

; Ex0_Cmd_3 (Triger command)
M_Cmd_3:    LCALL   ReceiveOneByte
            ANL     A, #003H
            XRL     uchSumCheck, A
            MOV     aUartRcvBuf+1, A
            LCALL   ReceiveOneByte
;            CJNE    A, uchSumCheck, MC3_L05
            SETB    bUARTRcvValid
MC3_L05:    AJMP    M_L01

M_Cmd_4:    LCALL   ReceiveOneByte
            CJNE    A, #05AH, MC5_L05
            LCALL   ReceiveOneByte
            CJNE    A, #0A5H, MC5_L05
            LCALL   Disable_WD
            LCALL   Soft_Reset
MC5_L05:    AJMP    M_L01
M_Cmd_5:    LCALL   Enable_WD
            LCALL   Soft_Reset
            AJMP    M_L01
M_Cmd_6:    MOV     SSTAT, #000H
            MOV     AUXR1, #0C0H
            AJMP    M_L01
M_Cmd_7:    MOV     SSTAT, #000H
            MOV     AUXR1, #080H
            AJMP    M_L01
M_Cmd_8:    LCALL   WaitForCapture
            AJMP    M_L01
M_Cmd_9:    AJMP    M_L01
M_Cmd_A:    LCALL   Soft_Reset
M_Cmd_B:    LCALL   ReceiveOneByte
            MOV     R5, A
            LCALL   ReceiveOneByte
            MOV     R7, A
            MOV     A, #02H
            LCALL   Pgm_Mtp
            AJMP    M_L01

M_Cmd_C:    SETB    bAuto_En
            AJMP    M_L01
	    CLR     bUARTRcvValid	
M_Cmd_D:    CLR     bAuto_En
	    CLR     bUARTRcvValid
            AJMP    M_L01

M_Cmd_E:    ;CLR     EX1
            SETB    bAutoCtlEnable
	    CLR     bUARTRcvValid
            AJMP    M_L01	
M_Cmd_F:    ;CLR     EX1
	    CLR     bAutoCtlEnable
	    CLR     bUARTRcvValid
            AJMP    M_L01

;Vertical(_bXSG1) interrupt. Priority Level 1
Isr_Ex0:    JNB     _bXSG1,EX0_M00
            RETI
EX0_M00:    JNB     _bXSG1,EX0_M01
            RETI
EX0_M01:    CLR     EX1
            PUSH    ACC
            PUSH    PSW
            JB      bXV2, $
            JB      _bXV3, EX0_L01
            JNB     _bXV3, $
            AJMP    EX0_L05
EX0_L01:    JB      _bXV3, $
            JNB     _bXV3, $
EX0_L05:    JB      _bXV3, $
            JNB     _bXV3, $
            JNB     bClrDogEnable, EX0_L06
            MOV     WFEED1, #0A5H
            MOV     WFEED2, #05AH
            CLR     bClrDogEnable
EX0_L06:    JB      _bXV3, $
            JNB     _bXV3, $
            JNB     bUARTRcvValid, EX0_L10
            MOV     DPTR, #EX0_TBL0
            MOV     A, aUartRcvBuf+0
            ANL     A, #003H
            RL      A

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -