The following is the assembly source code of Proteus simulation 320x240TFT color screen:
;Proteus7.5SP3, LCD driver: ---, LCD: 320x240 65K color, 8bit interface
;RGB(565) order (this simulated TFT sends low bits first and then high bits).
;Modified by HeFanghua, 2012-4-20
;Function: Read the BIN data file in AT25F4096 and display it on TFT, refresh the screen
;MCU for simulation test: AT89C55@12MHz or above.
; LCD coordinate axis direction (place the screen with the cables facing downwards):
;O 319
;┼────→ horizontal
;│
;│
;│239
;↓vertical
;-----
;Conversion of large image file data:
The asm format data table is split into 4 by the file splitter, each of which is assembled into BIN by WAVE, merged by batch COPY command, opened by UltraEdit in HEX mode and the extra 1 byte at the end is deleted.
;---Pin Definition---
TFT_RS equ P3.5 ;Data/command switch
TFT_RST equ P1.2 ; Reset
TFT_WR equ P3.6 ; write control
TFT_CS equ P3.7 ;Chip select
TFT_Data EQU P2; 8-bit mode data port
AT25F_SCK bit p1.7 ;AT25F4096(512KB SPI ROM)
AT25F_SI bit p1.6 ;MOSI
AT25F_SO bit p1.5 ;MISO
AT25F_CS bit p1.4
;AT25F_WP bit p1.2
;AT25F_HOLD bit p1.3
;---
;---Register definition---
I equ 3fh
J equ 40h
K equ 41h
VH equ 42h
VL equ 43h
colorH equ 44h
colorL equ 45h
;-----
;---Macro definition---
;---
ORG 0
LJMP MAIN
ORG 60H
;-----
main:
mov sp,#7fh
setb TFT_CS
call Address_set ;TFT initialization
call AT25F_SPIinit
;call AT25F_SPI_Write
call AT25F_SPI_Read
call delay1s
again:
mov colorH,#0f8h
mov colorL,#0
call Paint ; red
mov colorH,#7h
mov colorL,#0e0h
call Paint ; green
mov colorH,#0
mov colorL,#1fh
call Paint ; blue
mov colorH,#0ffh
mov colorL,#0e0h
call Paint ; yellow
mov colorH,#0f8h
mov colorL,#1fh
call Paint ; purple
mov colorH,#07h
mov colorL,#0ffh
call Paint ;Indigo
mov colorH,#0ffh
mov colorL,#0ffh
call Paint ; white
mov colorH,#0
mov colorL,#0
call paint ;TFT clear screen (black)
jmp again
;================
AT25F_SPIinit: ; Initialize 25T. SPI mode 0 (CPOL polarity = 0, CPHA phase = 0)
setb AT25F_CS
clr AT25F_SCK ;Required
; setb AT25F_WP
; setb AT25F_HOLD
setb AT25F_SO
setb AT25F_SI
right
AT25F_SPI_Write: ;For testing, write 1 byte
; clr AT25F_CS
; mov a,#00000010b
; call SPI_W1B
; mov a,#0 ; write address, 3 bytes
; call SPI_W1B
; move to,#0
; call SPI_W1B
; move to,#0
; call SPI_W1B
; rice r3, #256
; AT25F_SPI_Write_1:
; move a, r3; #5ah
; call SPI_W1B
; djnz r3,AT25F_SPI_Write_1
; mov a,#5ah
; call SPI_W1B
; setb AT25F_CS
right
AT25F_SPI_Read: ;Continuously read 25T memory
clr AT25F_CS
mov a,#00000011b ;Read Data from Memory Array
call SPI_W1B
mov a,#0 ; read address, 3 bytes
call SPI_W1B
move to,#0
call SPI_W1B
move to,#0
call SPI_W1B
;320x240 times=2x160x240
mov R7,#2
mov R6,#160
rice R5, #240
clr TFT_CS ; turn on chip select
SETB TFT_RS ;Send data
AT25F_SPI_Read_1:
call SPI_R1B
mov VH,a ;temporarily store the upper 8 bits
call SPI_R1B
mov TFT_Data,a
clr tft_wr
setb tft_cs
clr tft_cs
setb tft_wr
mov TFT_Data,VH
clr tft_wr
setb tft_cs
clr tft_cs
setb tft_wr
djnz R5,AT25F_SPI_Read_1
rice R5, #240
djnz R6,AT25F_SPI_Read_1
mov R6,#160
djnz R7,AT25F_SPI_Read_1
setb AT25F_CS
right
SPI_W1B: ; write 1 byte
mov r4,#8
clr AT25F_SCK
SPI_W1B_1:
rlc a
mov AT25F_SI,c
clr AT25F_SCK ; rising edge
setb AT25F_SCK
djnz r4,SPI_W1B_1
right
SPI_R1B: ; read 1 byte
setb AT25F_SI
setb AT25F_SO
mov r4,#8
SPI_R1B_1:
setb AT25F_SCK ; falling edge
clr AT25F_SCK
mov c,AT25F_SO
rlc a
djnz r4,SPI_R1B_1
clr AT25F_SCK
right
TFT_Write_Bus: ;Send data to TFT, input VH, VL. Send low bit first and high bit later
mov TFT_Data,VL
clr tft_wr
setb tft_cs
clr tft_cs
setb tft_wr
mov TFT_Data,VH
clr tft_wr
setb tft_cs
clr tft_cs
setb tft_wr
RIGHT
Address_set:
mov vh,#0 ;x starting address
mov vl,#0
CLR TFT_RS
clr TFT_CS
call TFT_Write_Bus
mov vh,#0 ;y starting address
mov vl,#0
call TFT_Write_Bus
right
Paint: ; Fill the entire screen with color, input colorH, colorL
clr TFT_CS ; turn on chip select
call Address_set ;proteus manually returns to the upper left corner
SETB TFT_RS ;Send data
MOV VH,colorH
MOV VL,colorL
mov R7,#160
mov R6,#240
Paint_1:
call TFT_Write_Bus ; send 2 bytes
call TFT_Write_Bus ; send 2 bytes
djnz R6,Paint_1
mov R6,#240
djnz R7,Paint_1
setb TFT_CS ; turn off chip select enable
right
delay1s:
MOV I,#0ABH
delay1s_2:
MOV J,#02DH
delay1s_1:
MOV K,#0B0H
DJNZ K,$
DJNZ J,delay1s_1
DJNZ I,delay1s_2
RIGHT
end
Previous article:Based on 51 single chip microcomputer serial port control LED light source program
Next article:Single chip electronic perpetual calendar with lunar calendar display
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- What will happen if the servo motor inertia is insufficient?
- How to select parameters for servo motor inertia size
- Types and Applications of Directional Couplers
- 19 "Ten Thousand Miles" Raspberry Pi Car——VSCode Learning (Multiple C File Link Debugging)
- What are the maskable interrupts of MSP430?
- I want a DAC+op amp circuit that can output about 15-30V.
- A 12-layer FPGA board drawn by KiCad
- Detailed description of how GaN devices can be used to design cost-effective 5G products
- 23 million Raspberry Pis have been sold
- Excellent materials: National undergraduate electronic design competition training course album
- Showing goods + almost 20 years old board
- LoRa Wireless Internet of Things wireless technology frequency band division