The transceiver program based on single chip microcomputer and 8279 driving digital tube display and communicating with the host computer

Publisher:幸福的时光Latest update time:2015-10-10 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;The system crystal is 11.0592 MHz

;Use the serial port debugging assistant to cooperate with the experiment
Z8279           EQU             0FF82H          ;8279 status/command port address
D8279           EQU             0FF80H          ;8279 data port address
LEDMOD          EQU             00H             ;Enter eight characters on the left
                               ;External decoding key scanning mode, double key interlock
LEDFEQ          EQU             33H             ;Scan rate
LEDCLS          EQU             0C1H            ;Clear display RAM
LEDWR0          EQU             80H             ;Set the display RAM address to be written
READKB          EQU             40H             ;Read the command word of FIFO RAM address 0

               ORG             0000H
               AJMP            START
               ORG             0040H
START:
               MOV             SP,#60H
               LCALL           INIT8279                ; Initialize 8279
               MOV             SCON,#50H               ; Serial port mode 1
               MOV             TMOD,#20H               ; T1 mode 1
               MOV             TL1,#0FDH               ; Constant of baud rate 9600
               MOV             TH1,#0FDH
               SETB            TR1               

                          SETB            EA
WAIT:
               JBC             RI,DIS_REC              ;Whether data is received
               LCALL           GETKEY                  ;Read keyboard
               CJNE            A,#0FFH,WAIT            ;Whether there is key input
               MOV             SBUF,B                  ;Serial port outputs the value of keyboard input
               NOP
SS:             JBC             TI,WAIT                 ;Whether sending is completed
               SJMP            SS

DIS_REC:
               MOV             A,SBUF                  ; Read the data received from the serial port
               CLR             C
               SUBB            A,#30H                  ; The following determines whether the input is between 0-F
               JC             ERROR
               SUBB            A,#0AH
               JNC             DIS_REC1
               ADD             A,#0AH
               SJMP            DIS_REC2
DIS_REC1:
               SUBB            A,#7H
               JC              ERROR
               SUBB            A,#6H
               JNC             ERROR
               ADD             A,#10H
DIS_REC2:
               MOV             R4,#00H
               MOV             R5,A
               LCALL           DISLED                  ; Display the input number (0-F)
ERROR:          AJMP            WAIT

INIT8279:                               ;8279 initialization subroutine
               PUSH           DPH                      ;Save the scene
               PUSH           DPL
               PUSH           ACC
               LCALL          DELAY                    ;Delay
               MOV            DPTR ,#Z8279
               MOV            A,#LEDMOD                ;Set 8279 working mode
               MOVX           @DPTR,A
               MOV            A,#LEDFEQ                ;Set keyboard scanning rate
               MOVX           @DPTR,A
               MOV            A,#LEDCLS                ;Clear LED display
               MOVX           @DPTR,A
               POP            ACC                      ;Restore the scene
               POP            DPL
               POP            DPH
               RET
;Read keyboard subroutine
;Input: None           ; Output: B: Read key code A: Key mark
GETKEY: PUSH           DPH                      ;Save the scene
               PUSH           DPL
               PUSH           PSW
               MOV            DPTR,#Z8279
               MOVX           A,@DPTR                  ;Read 8279 status
               ANL            A,#07H                   ;Shield D7-D3
               JNZ            GETVAL                   ;Judge whether there is key input
               MOV            A,#0H                    ;Set flag (no key input)
               SJMP           NKBHIT
GETVAL: MOV            A,#READKB                ;Read FIFO RAM command
               MOVX           @DPTR,A
               MOV            DPTR,#D8279
               MOVX           A,@DPTR                  ;Read key
               ANL            A,#0FH                   ;Shield SHIFT and CTRL keys
               MOV            DPTR,#KEYCODE            ;Key code table starting address
               MOVC           A,@A+DPTR                ;Look up the table
               MOV            B,A                      ;Set return key value
               MOV            A,#0FFH                  ;Set flag (key input)
NKBHIT: POP            PSW                      ;Restore the scene
               POP            DPL
               POP            DPH
               RET
;Display character subroutine
;Input: R4, position R5, value
DISLED:          PUSH           DPH                     ;Save the scene
                PUSH           DPL
                PUSH           ACC
                MOV            A,#LEDWR0               ;Set display starting address
                ADD            A,R4                    ;Add position offset
                MOV            DPTR,#Z8279
                MOVX           @DPTR,A                 ;Set display position
                MOV            DPTR,#LEDSEG            ;Set display constant table start position
                MOV            A,R5
                MOVC           A,@A+DPTR               ;Look up table
                MOV            DPTR,#D8279
                MOVX           @DPTR,A                 ;Display data
                POP            ACC                     ;Restore scene
                POP            DPL
                POP            DPH
                RET

DELAY:                                  ;Delay subroutine
               PUSH            0                       ;Save the scene
               PUSH            1
               MOV             0,#0H
DELAY1: MOV             1,#0H
               DJNZ            1,$
               DJNZ            0,DELAY1
               POP             1                       ;Restore the scene
               POP             0
               RET
;LED display constant table
LEDSEG: DB              3FH,06H,5BH,4FH,66H,6DH,7DH,07H
               DB              7FH,6FH,77H,7CH,39H,5EH,79H,71H
               DB              0BFH,086H,0DBH,0CFH,0E6H,0EDH,0FDH,087H
               DB              0FFH,0EFH,0F7H,0FCH,0B9H,0DEH,0F9H,0F1H
               DB              6DH,02H,08H,00H,59H,0FH,76H      
;Keyboard key code table
KEYCODE: DB              30H,31H,32H,33H,34H,35H,36H,37H
               DB              38H,39H,41H,42H,43H,44H,45H,46H
               DB              47H,48H,49H,4AH,4BH,4CH,4DH,4EH
               END

Keywords:MCU Reference address:The transceiver program based on single chip microcomputer and 8279 driving digital tube display and communicating with the host computer

Previous article:Serial communication program for two 51 single-chip microcomputers to communicate with each other
Next article:51 MCU MPU6050 module data reading and display

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号