首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

请各位前辈帮我改一下9s12A128控制CM240128的汇编程序

请各位前辈帮我改一下9s12A128控制CM240128的汇编程序

第一次用飞思卡尔的单片机,要用汇编来写一个液晶的程序,没有找到这方面的资料,就自己模仿网上找到的51单片机控制这款液晶的程序写了一个,液晶没显示,不知道为什么?请各位前辈指点指点,谢谢了

主控制器:mc9s12a128 液晶:mc240128(控制芯片是T6963),PK5接LCDRST,PK4接WR,PJ1接C/D,PJ0接RD,PH0-PH7接D0-D7

程序如下:

;**************************************************************
;* This stationery is serves as the framework for a *
;* user application. For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of the *
;* Metrowerks CodeWarrior for the HC12 Program directory *
;**************************************************************

; export symbols
XDEF Entry, main
; we use export 'Entry' as symbol. This allows us to
; reference 'Entry' either in the linker .prm file
; or from C/C++ later on

; include derivative specific macros
INCLUDE 'mc9s12a128.inc'

; variable/data section
MY_EXTENDED_RAM: SECTION
; Insert here your data definition. For demonstration, temp_byte is used.
;test_byte ds.b 1
DATA EQU $44
COMMAND EQU $45
C_ADD EQU $30
D_ADD EQU $31
TEST: DC.B $FF,$00,$FF,$00,$FF,$00,$FF,$00
DC.B $00,$FF,$00,$FF,$00,$FF,$00,$FF
DC.B $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
DC.B $55,$55,$55,$55,$55,$55,$55,$55 ;????
DC.B $AA,$55,$AA,$55,$AA,$55,$AA,$55
DC.B $55,$AA,$55,$AA,$55,$AA,$55,$AA
; code section
MyCode: SECTION
WRITE_COMMAND:
PSHA
PSHD
BSET 1,mPTIJ_PTIJ1
MOVW #C_ADD,PPAGE
LDD PPAGE
NOP
LDAA COMMAND
MOVW #C_ADD,PPAGE
STAA PPAGE ;????
BSET 0,mPORTK_BIT4
NOP
BSET 1,mPORTK_BIT4
BSET 0,mPTIJ_PTIJ1
PULD
PULA
RTS
WRITE_DATA:
PSHD
PSHA
BSET 0,mPTIJ_PTIJ1
MOVW #D_ADD,PPAGE
LDD PPAGE
NOP
LDAA DATA
MOVW #D_ADD,PPAGE
STAA PPAGE
BSET 0,mPORTK_BIT4
NOP
BSET 1,mPORTK_BIT4
BSET 1,mPTIJ_PTIJ1
PULD
PULA
NOP
NOP
RTS
DELAY:
PSHA
LDAA #$10
XX: DBNE A,XX
PULA
RTS



main:
Entry:
CLI ; enable interrupts


LDS #$1FFF
NOP
; BCLR 1,mPORTK_BIT5
BSET 0,mPORTK_BIT4
MOVB #$FF,DDRH
NOP
BSET 1,mPORTK_BIT4
BSET 1,mPTIJ_PTIJ0
MOVB #$90,COMMAND
JSR WRITE_COMMAND
JSR DELAY
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$40,COMMAND
JSR WRITE_COMMAND
MOVB #$20,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$41,COMMAND
JSR WRITE_COMMAND
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$08,DATA
JSR WRITE_DATA
MOVB #$42,COMMAND
JSR WRITE_COMMAND
MOVB #$1E,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$43,COMMAND
JSR WRITE_COMMAND
MOVB #$80,COMMAND
JSR WRITE_COMMAND
MOVB #$9C,COMMAND
JSR WRITE_COMMAND
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND

LDAA #$01 ;;;;;????
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
LDAB #$20
YY1:
NOP
YY:
MOVB #$FF,DATA
JSR WRITE_DATA
DBNE A,YY
DBNE B,YY1
MOVB #$B2,COMMAND
JSR WRITE_COMMAND
JSR DELAY
CLEAR1:
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND
LDAA #$01 ;;;;????
LDAB #$20
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
M1: NOP
M: MOVB #$00,DATA
JSR WRITE_DATA
DBNE A,M
DBNE B,M1
MOVB #$B2,COMMAND
JSR WRITE_COMMAND

MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND
MOVB #$9C,COMMAND
JSR WRITE_COMMAND
MOVB #$05,DATA
JSR WRITE_DATA
MOVB #$03,DATA
JSR WRITE_DATA
MOVB #$21,COMMAND
JSR WRITE_COMMAND
LDAB #$7F
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
LDAA #$FF
L: INCA
STAA DATA
JSR WRITE_DATA
DBNE B,L
MOVB #$B2,COMMAND
JSR WRITE_COMMAND
JSR DELAY



MOVB #$03,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$22,COMMAND
JSR WRITE_COMMAND
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$1C,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND
LDAA #$02
LDAB #$FF
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
MOVW #TEST,PPAGE ;????
NN2: NOP
NN: CLR X
LDX PPAGE
MOVB X,DATA
JSR WRITE_DATA
INC PPAGE
DBNE A,NN
DBNE B,NN2
MOVB #$B2,DATA ;;;;????
JSR WRITE_DATA


MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
LDAA #$02

TZ1:
LDAB #$FF
QQ1:
MOVB #$80,DATA
JSR WRITE_DATA
DBNE B,QQ1
DBNE A,TZ1
MOVB #$B0,COMMAND
JSR WRITE_COMMAND
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$00,DATA
JSR WRITE_DATA
MOVB #$24,COMMAND
JSR WRITE_COMMAND

LBRA main

返回列表