51 MCU Proteus simulation 320x240TFT color screen

Publisher:AsawenLatest update time:2020-08-05 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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


Reference address:51 MCU Proteus simulation 320x240TFT color screen

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

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号