Songhan MCU 1602

Publisher:沈阳阿荣Latest update time:2015-07-06 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
 CHIP SN8F27E65

//{{SONIX_CODE_OPTION
 .Code_Option WDT_CLK Flosc/4
 .Code_Option Reset_Pin P04
 .Code_Option LVD LVD_Max ; 3.3V Reset
 .Code_Option Watch_Dog Disable ;Turn off the
 watchdog.Code_Option Low_Fcpu Flosc/1
 .Code_Option High_Clk IHRC_16M ; Internal 16M RC Oscillator
 .Code_Option High_Fcpu Fhosc/1
 .Code_Option Security Enable
 .Code_Option Noise_Filter Enable
//}}SONIX_CODE_OPTION
 DATA EQU P4 ;Data port
 DATAM EQU P4M
 
 RS EQU P0.0 ;Data/command
 RSM EQU P0M.0
 
 RW EQU P0.1 ;Read/write
 RWM EQU P0M.1
 EEQU P0.2 ; Control enable
 EM EQU P0M.2

 ORG 0000H
 JMP A1
 ORG 0015H
A1: MOV A,#30H;Display content
 MOV 41H,A
 MOV A,#31H
 MOV 42H,A
 MOV A,#32H
 MOV 43H,A
 MOV A,#33H
 MOV 44H,A
 
 MOV A,#01H;Clear screen
 MOV 30H,A
 CALL ZL01
 MOV A,#250
 MOV 31H,A
A2: 
 MOV A,#38H;Set display mode 5*7 dots
 MOV 30H,A
 CALL ZL01
 DECMS 31H
 JMP A2
 
 MOV A,#0CH;Turn on display and turn off cursor
 MOV 30H,A
 CALL ZL01
 
 CALL XS01;Display subroutine
 
 JMP $
;****************************************************
;Display subroutine
;*************************************************  
XS01: MOV A,#38H;Set display mode
 MOV 30H,A 
 CALL ZL01
 MOV A,#0CH;Turn on display
 MOV 30H,A
 CALL ZL01
 MOV A,#0C8H;Display starting position
 MOV 30H,A
 CALL ZL01
 
 B0MOV H,#0 ; Clear "H" to address RAM bank 0.
 B0MOV L,#41H ; Set register address.
XS02: MOV A,@HL;Display content processing
 MOV 30H,A
 CALL SJ01
 INCMS L;Display next data
 MOV A,L
 CMPRS A,#45H;Is the display completed?
 JMP XS02
 RET
;********************************************
;Write command subroutine
;********************************************    
ZL01: MOV A,#0FFH;Set the data port to output state
 MOV DATAM,A
 MOV DATA,A;Output high level
 
 B0BSET RSM;Set to data mode
 B0BCLR RS
 
 B0BSET RWM;Set to read mode
 B0BSET RW
 
 B0BSET EM;Allow operation
 B0BSET E
ZL02:
 B0BCLR P4M.7;Busy check
 B0BTS0 P4.7;P4.7=1 busy, P4.7=0 idle
 JMP ZL02
 B0BSET EM;Turn off enable
 B0BCLR E
 
 B0BSET RSM; Set to command mode
 B0BCLR RS
 
 B0BSET RWM; Set to write mode
 B0BCLR RW
 
 MOV A,#0FFH; Output the content to be written to the data port
 MOV DATAM,A
 MOV A,30H
 MOV DATA,A
 
 B0BSET EM; Allow the enable operation
 B0BSET E
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 B0BSET EM; Turn off enable
 B0BCLR E
 
 RET
;********************************************
; Write data subroutine
;****************************************
SJ01: MOV A,#0FFH
 MOV DATAM,A
 MOV DATA,A
 
 B0BSET RSM
 B0BCLR RS
 
 B0BSET RWM
 B0BSET RW
 
 B0BSET EM
 B0BSET E
SJ02:
 B0BCLR P4M.7
 B0BTS0 P4.7
 JMP SJ02
 
 B0BSET EM
 B0BCLR E
 
 B0BSET RSM; Set to data mode
 B0BSET RS
 
 B0BSET RWM
 B0BCLR RW
 MOV A,#0FFH
 MOV DATAM,A
 MOV A,30H
 MOV DATA,A
 
 B0BSET EM
 B0BSET E
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 NOP
 B0BSET EM
 B0BCLR E
 
 RET
 ENDP

Reference address:Songhan MCU 1602

Previous article:Songhan MCU independent button
Next article:Learning experience of AVR and PIC microcontrollers

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号