打印
[STM32F1]

stm32纯汇编LCD显示

[复制链接]
1306|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yjmwxwx|  楼主 | 2015-5-24 13:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
板子是正点原子的miniSTM32开发板,读液晶返回的ID是4535(程序中没用读液晶代码)。

程序实现时钟初始化、IO设置、LCD初始化、LCD画背景色、LCD显示字符几个部分。

红底蓝子大概在中间位置显示:
   STM32ASM
   YJMWXWX
   2015-05-21                                                
程序不大,搞了两天才弄出来。程序代码极其不规范,没有利用堆栈传送数据等
工具链 gcc-arm-none-eabi


      .thumb                 
        .syntax unified

.section .data
lcdcsh:
    .short 0x0000,0x0001,0x0015,0x0030,0x009a,0x0010,0x0011,0x0020,0x0010,0x3428,0x0012,0x0002,0x0013,0x1038,0x0012,0x0012,0x0010,0x3420,0x0013,0x3038,0x0030,0x0000,0x0031,0x0402,0x0032,0x0307,0x0033,0x0304,0x0034,0x0004,0x0035,0x0401,0x0036,0x0707,0x0037,0x0305,0x0038,0x0610,0x0039,0x0610,0x0001,0x0100,0x0002,0x0300,0x0003,0x1030,0x0008,0x0808,0x000a,0x0008,0x0060,0x2700,0x0061,0x00001,0x0090,0x13e,0x0092,0x0100,0x0093,0x0100,0x00a0,0x3000,0x00a3,0x0010,0x0007,0x0001,0x0007,0x0021,0x0007,0x0023,0x0007,0x0033,0x0007,0x0133

shijian:    .ascii "2015-05-21"
AYJMWXWX:  .ascii "YJMWXWX"
ASTM32ASM: .ascii "STM32ASM"

lcdmabiao:
    .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00,0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08,0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00,0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00,0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00,0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00,0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00,0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00,0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F,0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00,0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00,0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00,0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00,0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00,0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00
   

        .equ STACKINIT,     0x20005000
    .equ lcdyanshia,     40000

   
.section .text
vectors:        
        .word STACKINIT         
        .word _start + 1        
        .word _nmi_handler + 1  
        .word _hard_fault  + 1  
        .word _memory_fault + 1
        .word _bus_fault + 1   
        .word _usage_fault + 1
    .word 0
    .word 0
    .word 0
    .word 0
    .word 0
    .word 0
    .word 0
    .word 0
    .word _dingshiqi + 1

_start:

@@AFIO-MAPR 开SWD模式
    ldr r0, = 0x40010004
    ldr r1, = 0x02000000
    str r1, [r0]
shizhong:
    ldr r0, = 0x40021000
    ldr r1, = 0x14D83
    str r1, [r0]
gsszbz:
    ldr r2, [r0]
    ldr r1, = 0x20000
    tst r1, r2           @高速时钟标志位           
    bne rccchushihua
    b gsszbz
rccchushihua:
    ldr r0, = 0x40022000
    mov r1, # 0x00000032
    str r1, [r0]           @FLASH缓冲 缓冲开启
    ldr r0, = 0x40021004
    ldr r1, = 0x1D8400
    str r1, [r0]
    ldr r0, = 0x40021000
    ldr r1, = 0x1033D03
    str r1, [r0]
chaxun:
    ldr r2, [r0]
    ldr r1, = 0x2000000
    tst r1, r2
    bne rccgg
    b chaxun
rccgg:
    ldr r0, = 0x40021004
    ldr r1, = 0x1D8402
    str r1, [r0]
ioshezhi:

       ldr r6, = 0x40021018
        mov r0, 0x39
        str r0, [r6]
    @@AFIO-MAPR 开SWD
    ldr r0, = 0x40010004
    ldr r1, = 0x02000000
    str r1, [r0]
    ldr r0, = 0x40011000
    ldr r1, = 0x33444444
    str r1, [r0]
    ldr r1, = 0x44444333
    str r1, [r0, # 4]
    ldr r1, = 0x7c0
    str r1, [r0, # 0xc]
    ldr r0, = 0x40010C00
    ldr r1, = 0x33333333
    str r1, [r0]
    ldr r1, = 0x33333333
    str r1, [r0, # 4]
    ldr r1, = 0xffff
    str r1, [r0, # 0xc]
    ldr r5, = lcdyanshia
    mov r6, # 0
    mov r2, # 0
lcdchushihua:
    add r6, # 1
    ldr r0, = lcdcsh
    ldrh r4, [r0, r2]
    add r2, # 2
    ldrh r7, [r0, r2]
    add r2, # 2
    cmp r6, # 1
    beq yanshi1
    cmp r6, # 7
    beq yanshi1
    cmp r6, # 8
    beq yanshi1
    cmp r6, # 10
    beq yanshi1
    bl lcdchushihua2
   
lcd1:
    cmp r2, # 0x94
    bhi tiaochu
    b lcdchushihua
   
yanshi1:
    bl lcdchushihua2
    bl yanshi
    b lcd1
tiaochu:
    mov r2, # 0
    mov r8, # 0
    mov r9, # 0
    ldr r10, = 0xf800
xxxxxx:
    mov r4, # 0x20
    mov r7, r8
    bl lcdchushihua2
    add r8, # 1
    cmp r8, # 240
    bne yyyyyy
    mov r8, # 0
    b tiaochuyanse
yyyyyy:
    mov r4, # 0x21
    mov r7, r9
    bl lcdchushihua2
    add r9, # 1
    cmp.w r9, # 320
    bne xielcd
    mov r9, # 0
    b xxxxxx
xielcd:
    mov r4, # 0x22
    mov r7, r10
    bl lcdchushihua2
    b yyyyyy

lcdchushihua2:
    push {r0,r1,r3,r7,lr}
    ldr r0, = 0x4001100c
    mov r1, # 0x4c0
    str r1, [r0]
    ldr r3, = 0x40010c0c
    str r4, [r3]
    mov r1, # 0x440
    str r1, [r0]
    mov r1, # 0x7c0
    str r1, [r0]
    mov r1, # 0x5c0
    str r1, [r0]
    str r7, [r3]
    mov r1, # 0x540
    str r1, [r0]
    mov r1, # 0x7c0
    str r1, [r0]
    pop {r0,r1,r3,r7,pc}
   
lcdxiedongxi:
    push {r0-r12, lr}
    mov r3, # 0
    mov r8, # 0
    mov r9, # 0
qulcdma:
    ldr r11, = lcdmabiao   
        ldrb r1, [r0, r3]
    add r3, # 1
    sub r4, r1, # 32
    mov r7, # 16
    mul r4, r4, r7
    add r11, r4
    ldr r1, = 0x20000200
    ldr r1, [r1]
    cmp r3, r1
    bne xiezi
    mov r3, # 0
    pop {r0-r12, pc}
   
   
xiezi:
    ldrb r6, [r11, r8]
    mov r4, # 0x21
    add r7, r8, r2
    bl lcdchushihua2
    add r8, # 1
    cmp r8, # 16
    bne  xiezi1
    mov r8, # 0
    add r12, # 8
    cmp r12, # 240
    bls qulcdma
    mov r12, # 0
    add r2, # 32
    cmp r2, # 320
    bls qulcdma
    mov r2, # 0
    b qulcdma
   
xiezi1:
    mov r4, # 0x20
    add r7, r9, r12
    bl lcdchushihua2
    add r9, # 1
    cmp r9, # 8
    bne lcdyu
    mov r9, # 0
    b xiezi
lcdyu:
    tst r6, # 0x01
    bne lcdxiezi
lcdxiezi1:
    mov r4, # 0x22
    movw r7, # 0xf800
    bl lcdchushihua2
    ror r6, # 1
    b xiezi1
lcdxiezi:
    mov r4, # 0x22
    mov r7, # 0x1f
    bl lcdchushihua2
    ror r6, # 1
    b xiezi1
yanshi:   
    subs r5, # 1
    bne yanshi
    ldr r5, = lcdyanshia
    bx lr
   
tiaochuyanse:
    ldr r0, = 0x20000200  @ 显示位数
    mov r1, # 9
    str r1, [r0]
    mov r2, # 64           @ 列偏移
    mov r12, # 32          @ 行偏移
    ldr r0, = ASTM32ASM    @ 显示的东西
    bl lcdxiedongxi
    ldr r0, = 0x20000200
    mov r1, # 8
    str r1, [r0]
    mov r2, # 80
    mov r12, # 32
    ldr r0, = AYJMWXWX
    bl lcdxiedongxi
    ldr r0, = 0x20000200
    mov r1, # 11
    str r1, [r0]
    mov r2, # 96
    mov r12, # 32
    ldr r0, = shijian
    bl lcdxiedongxi
xiewandongxi:
    b xiewandongxi
   

_nmi_handler:
    bx lr
_hard_fault:
    bx lr
_memory_fault:
    bx lr
_bus_fault:
    bx lr
_usage_fault:
    bx lr
_dingshiqi:   
    bx lr
         







stm32asm_lcd.zip (13.82 KB)






沙发
戈卫东| | 2015-5-24 14:17 | 只看该作者
楼主你辛苦了。。。。。

使用特权

评论回复
板凳
wind~风| | 2015-5-24 14:58 | 只看该作者
看着都觉得费劲儿

使用特权

评论回复
地板
大秦正声| | 2015-5-24 17:48 | 只看该作者
学习!

使用特权

评论回复
5
eurphan| | 2015-5-24 19:59 | 只看该作者
还是c语言好

使用特权

评论回复
6
taoest| | 2015-5-25 13:00 | 只看该作者
吃得好饱

使用特权

评论回复
7
SLHSu37| | 2015-5-25 14:38 | 只看该作者
看不懂·········

使用特权

评论回复
8
周董| | 2015-5-25 20:45 | 只看该作者
汇编

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

117

主题

2719

帖子

48

粉丝