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

📄 init_ask.asm

📁 基于MOTOLOLAR单片机的TPMS发送控制器代码设计
💻 ASM
字号:
;/*****************************************************************************/
;/* PROJECT : Mosport State Machine Mimic   MODULE : State_0a   (No Tx here)  */
;/* Functions: (Initialization mode, occurs upon power-up)                    */
;/*  Init                                                                     */
;/*  Init_ports                                                               */
;/*  Init_KBI                                                                 */
;/*  Init_ICG                                                                 */
;/*****************************************************************************/
; Version 1 --Jeff Burgess (Adapted from Eric Perraud RKE Code)
;/*****************************************************************************/
;/* Init_KBI                                                                  */
;/* Description : it enables keyboard interrupts                              */
;/* In :                                                                      */
;/* Out : INTKBSR, INTKBIER                                                   */
;/* local variables :                                                         */
;/*****************************************************************************/

Init_KBI:
        bset    1,INTKBSR       ; mask keyboard interrupt
        bset    5,INTKBSR       ; & IRQ
        bset    6,INTKBSR       ; clear the pending IRQ request
        bset    2,INTKBSR       ; clear the pending keyboard request
        bclr    0,INTKBSR       ; keyboard interrupt triggered by falling edge only
        bset    3,INTKBIER      ; enable keyboard interrupt KBD3 to wakeup from stop
                                ; by Daytona
        bclr    1,INTKBSR       ; enable keyboard interrupts
        rts

;/*****************************************************************************/
;/* Init_ICG                                                                  */
;/* Description : it initializes the ICG @ 2 MHz                              */
;/* In :                                                                      */
;/* Out : ICGCR, ICGMR                                                        */
;/* local variables :                                                         */
;/*****************************************************************************/

Init_ICG:
        mov     #$08,ICGCR      ; mcu clk = internal clock
        mov     #$1A,ICGMR      ; mcu clk = 2.000 MHz
        brclr   2,ICGCR,*       ; wait for PLL stable

        rts

;/*****************************************************************************/
;/* Init_Timer                                                                */
;/* Description : it initializes the timer to use the internal clock.  The    */
;/*    timer is re-configured for transmission then returns to this default.  */
;/* In :                                                                      */
;/* Out : TSC                                                                 */
;/* local variables :                                                         */
;/*****************************************************************************/

Init_Timer:
        lda     TSC
        mov     #%00110000,TSC  ;Clear & stop the timer, disable interrupts

        rts

;/*****************************************************************************/
;/* Init_ports                                                                */
;/* Description : it initializes MCU ports                                    */
;/* In :                                                                      */
;/* Out : ICGCR, ICGMR                                                        */
;/* local variables :                                                         */
;/*****************************************************************************/

Init_ports:
        clr     DDRA
        clr     DDRB

; Initialize Tango3 control (not quite enough pins on PORTB, Mode uses PORTA)

        mov     #$07,DDRB       ; DDRB=#%00000111
                                ; PTB0 - BAND       OUTPUT
                                ; PTB1 - ENABLE     OUTPUT
                                ; PTB2 - DATA       OUTPUT
                                ; PTB3 - DATACLK    INPUT

                                ; PTA7 - MODE       OUTPUT (Initialized below)

; Initialize Daytona Control (and one pin for Tango3 control)

        mov     #$B6,DDRA       ; DDRA=#%10110110
                                ; PTA0 - unused    -
                                ; PTA1 - S1/Vpp    OUTPUT
                                ; PTA2 - S0        OUTPUT
                                ; PTA3 - DOUTb     INPUT
                                ; PTA4 - DCLK      OUTPUT
                                ; PTA5 - DDATA     OUTPUT
                                ; PTA6 - unused    -
                                ; PTA7 - MODE      OUTPUT (to Tango3, see above)

        clr     PORTA
        clr     PORTB

        bclr    Mode,PORTA      ; Set Tango into ASK mode
        bset    Band,PORTB      ; Set Tango for 434/315 MHz transmission

        rts

;/*****************************************************************************/
;/* Init                                                                      */
;/* Description : it initializes the MCU                                      */
;/* In :                                                                      */
;/* Out :                                                                     */
;/* local variables :                                                         */
;/*****************************************************************************/

Init:
        clra
        clrx
        bsr     Init_ports
        bsr     Init_ICG
        bsr     Init_Timer

        clr     Tx_count
        clr     Max_Pres
        mov     #$FF,Min_Pres
        clr     STATUS

        mov     #$80,TEMPERATURE
        mov     #$80,PRESSURE   ; These initialize the values to 1/2 FS
                                ; for the moving average.  This way, the readings will
                                ; probably converge to the mean quicker than with whatever
                                ; random value these variables start at.

        bsr     Init_KBI

        rts

⌨️ 快捷键说明

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