pt2262 source code written by EM78P156

Publisher:幸福之星Latest update time:2018-01-29 Source: eefocusKeywords:EM78P156  pt2262 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

pt2262 source code written by EM78P156

;this program is HOME ALARM 
      ;
      n
      ;this progam write and test for 01.2.18---3.5

      ;Chip EM78P156   F=3.58 MHz
      ;SETUP : CYCLE=2,CLOCK=4,ENABLE WDT


      ;define ram
      ;**********************************************************
      IND         ==       0
      RTC         ==       1
      PC          ==       2
      STATUS      ==       3
      FSR         ==       4
      RA          ==       5
      RB          ==       6

      ;define hundred bit
      ;************************************************************
      C == 0
      Z == 2

      ;define ra bit
      ;**********************************************************
      R0          ==       0             
      R1          ==       1                
      R2          ==       2             
      R3          ==       3            

      ;define rb bit
      ;**********************************************************

      SEND        ==       1             
      RFIN        ==       4             REC RF IN

      ;DEFINE INTR
      ;**********************************************************
      INTR        ==       0xf
      TCIF        ==       0
      ICIF        ==       1
      EXIF        ==       2

      ;define cont bit
      ;**********************************************************
      PAB         ==       3
      TE          ==       4
      TS          ==       5
      INT_FLG     ==       6

      ;DEFINE PULL_DOWN
      ;**********************************************************
      IOCB        ==       0xb

      ;DEFINE OPEN_DRAIN
      ;**********************************************************
      IOCC        ==       0xc

      ;DEFINE PULL_HIGH
      ;**********************************************************
      IOCD        ==       0xd

      ;define wdt bit
      ;************************************************************
      IOCE == 0xe
      ROC == 4
      EIS == 6
      WDTE == 7

      ;DEFINE INT MASK
      ;**********************************************************
      IOCF        ==       0xf
      TCIE        ==       0
      ICIE        ==       1
      EXIE        ==       2

      ;define ram
      ;**********************************************************
      FLG1        ==       0x10          KEY STATUS
      FLG2        ==       0x11

      TEMP1       ==       0x12
      TEMP2       ==       0x13 
      TEMP3       ==       0x14

      TIME        ==       0x18
      BITCNT      ==       0x19

      CODECNT     ==       0x1f
      ;
      ;DEFINE FLG1 SEND IR
      ;**********************************************************
      ENTX        ==       7
      RELEASE     ==       0
      ;
      ;##########################################################
      ;**********************************************************
                  ORG      0x0
                  JMP      RESET
                  NOP
                  NOP      
                  NOP
                  NOP
                  NOP
                  NOP
              
                  ORG      0x10
      ;#########################################################
      D4ms:
                  MOV      A,@0x1f
                  JMP      DLYX
      D120us      MOV      A,@0x1
      DLYX:
                  MOV      TEMP1,A
      DLY:        MOV      A,@0xf
                  MOV      TEMP2,A
      DLY4        NOP
                  DJZ      TEMP2
                  JMP      DLY4
                  DJZ      TEMP1
                  JMP      DLY
                  RET
      ;##########################################################
      ;*****************PROGAM RESET*****************************
      RESET:       
                  MOV      A,STATUS 
                  AND      A,@0x18       GET TO PD
                  JBC      STATUS,Z      
                  JMP      MAIN1    
                  CLR      FLG1          CLR ALL FLAG
                  CLR      FLG2          
      MAIN1:                             
                  MOV      A,@0xf8       DIABLE PULL_DOWN
                  IOW      IOCB
                  MOV      A,@0x0        DISABLE OPEN_DRAIN
                  IOW      IOCC
                  MOV      A,@0xfe       RB0 PULL HIGH,DISABLE  PULL_HIGH
                  IOW      IOCD
                  MOV      A,@0x80       ENABLE WDT, INT
                  IOW      IOCE
                  MOV      A,@0x0        ENABLE EX_INT
                  IOW      IOCF
                  MOV      A,@0x0        RA IN
                  MOV      RA,A
                  MOV      A,@0x13        
                  MOV      RB,A
                  CLR      INTR
      MAIN2:
                  WDTC   
                  MOV      A,@0x0        SELECT SCAL WDT=1:2
                  CONTW                  DISABLE INT
                  NOP
                  NOP
                  NOP
                  MOV      A,@0xf
                  IOW      RA
                  MOV      A,@0x11
                  IOW      RB
      SEND_RF:
                  WDTC
                  BS      RB,SEND
                  BC      RB,2
                  BC      RB,3
                  JBS     FLG1,RELEASE
                  JBS     RA,1
                  JMP     SEND_RF_OVER
                  BS      FLG1,RELEASE
                  MOV     A,@0x2
                  MOV     TIME,A
      SEND_SYNC:            
                             
                  MOV     A,@0x10
                  MOV     BITCNT,A
      SEND_ADDR:
                  BC      RB,SEND
                  CALL    D120us
                  BS      RB,SEND
                  CALL    D120us
                  CALL    D120us
                  CALL    D120us
                 
                  DJZ     BITCNT
                  JMP     SEND_ADDR
                  MOV     A,@0x8
                  MOV     BITCNT,A
      SEND_DATA:
                  BC      RB,SEND
                  CALL    D120us
                  CALL    D120us
                  CALL    D120us
                  BS      RB,SEND
                  CALL    D120us
                  
                  DJZ     BITCNT
                  JMP     SEND_DATA
                  
                  BC      RB,SEND
                  CALL    D120us
                  BS      RB,SEND
                  WDTC
                  CALL    D4ms
                  CALL    D120us
                  CALL    D120us
                  CALL    D120us
                  CALL    D120us
                  DJZ     TIME
                  JMP     SEND_SYNC

      SEND_RF_OVER: 
                  NOP
                  BS      RB,SEND
                  JMP     MAIN1 
 


Keywords:EM78P156  pt2262 Reference address:pt2262 source code written by EM78P156

Previous article:EM78C156E+1621 display assembly example
Next article:Misunderstandings and skills in the application of EMC8BIT microcontroller instructions

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号