Eclipse development and debugging of ARM bare metal programs (Part 7) LCD

Publisher:SereneDreamerLatest update time:2016-06-06 Source: eefocusKeywords:Eclipse Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
       I originally thought that this LCD should be difficult to make, but I made it in an hour, and spent 2 hours to organize it to make my code look better. This time I can't use the simplest code to implement it like I2C. Displaying a picture requires a large image, and 4k sdram is not enough, so I have to use SDRAM. The nand, sdram, clock, and waterc_dog used for startup are all previous modules. Basically, they can be used directly, and it is not too difficult. In order to make the code have the characteristics of debugging and running at the same time. I remembered the solution of u-boot to this problem and followed it, and the effect is not bad. The principle is very simple, just make a judgment before copy_to_ram_from_nand. If the running address of _start is the link address, it means it is in debugging, so no copying is performed; if not, copying is performed. The specific code is as follows:
 
relocate: /* relocate U-Boot to RAM */
adrr0, _start /* r0 <- current position of code */
ldrr1, =TEXT_BASE /* test if we run from flash or RAM */
cmpr0, r1 /* don't reloc during debug */
beq stack_setup
 
ldr sp, =1024*4 @ Set up the stack
    bl copy_to_ram_from_nand @ to SDRAM
 
The comments are not changed, but it is really easy to use. The complete startup code is as follows:
@*
@File:start.S
@ Function: Set up SDRAM, transfer program to SDRAM, and then jump to SDRAM to continue execution
@*       
 
.equ MEM_CTL_BASE, 0x48000000
.equ TEXT_BASE, 0x33F80000
 
.text
.global _start
_start:
 
bl pre_lowlevel_init @ Turn off WATCHDOG and shield interrupts
bl system_clock_init
bl mem_ctrl_asm_init @ Set up the memory controller
bl nand_asm_init
 
relocate: /* relocate U-Boot to RAM */
adr r0, _start /* r0 <- current position of code */
ldr r1, =TEXT_BASE /* test if we run from flash or RAM */
cmp r0, r1 /* don't reloc during debug */
beq stack_setup
 
ldr sp, =1024*4 @ Set up the stack
    bl copy_to_ram_from_nand @ to SDRAM
 
stack_setup:
ldr sp, =0x33F80000 @ Set up the stack
 
ldr pc, _start_armboot @ Jump to SDRAM and continue execution
 
_start_armboot: .word main
 
@stack_setup:
@ ldr sp, =1024*4 @ Set up the stack
@bl main
 
halt_loop:
    b halt_loop
 
/*
 * Board-level initialization preprocessing function
 * Turn off watchdog and shield interrupt
 */
pre_lowlevel_init:
/* turn off the watchdog */
    #define pWTCON 0x53000000
    #define INTMSK 0x4A000008/* Interrupt-Controller base addresses */
    #define INTSUBMSK 0x4A00001C
    #define CLKDIVN 0x4C000014/* clock divisor register */
 
ldr r0, =pWTCON
mov r1, #0x0
str r1, [r0]
 
/*
 * mask all IRQs by setting all bits in the INTMR - default
 */
mov r1, #0xffffffff
ldr r0, =INTMSK
str r1, [r0]
 
ldr r1, =0x7fff
ldr r0, =INTSUBMSK
str r1, [r0]
 
mov pc, lr
/* end_of pre_lowlevel_init */
 
/*
 * System clock initialization function
 * S3C2440: FCLK:HCLK:PCLK = 1:4:8(FCLK is 405 MHz)
 */
#define CLKDIVN 0x4C000014
#define CLK_CTL_BASE 0x4C000000
#define MDIV_405 0x7f << 12
#define PSDIV_405 0x21
#define MDIV MDIV_405
#define PSDIV PSDIV_405
#define CLKDIV 0x5 /* FCLK:HCLK:PCLK = 1:4:8 */
 
system_clock_init:
ldr r0, =CLKDIVN
mov r1, #CLKDIV
str r1, [r0]
/*
     * Set arm920t to asynchronous clock mode
     *
     * When reset, arm920t is in fast bus clock mode.
     * Both core and AMBA are controlled by BCLK. After setting to asynchronous mode, core
     * Controlled by FCLK
     */
mrc p15, 0, r1, c1, c0, 0
orr r1, r1, #0xc0000000
mcr p15, 0, r1, c1, c0, 0
 
mov r1, #CLK_CTL_BASE
mov r2, #MDIV
add r2, r2, #PSDIV
str r2, [r1, #0x04] /* MPLLCON */
 
mov pc, lr
/* end_of system_clock_init*/
 
/*
 * NAND FLASH initialization function
 * TACLS:TWRPH0:TWRPH1 = 1:2:1, BUS_WIDTH_8
 */
#define S3C2440_NAND_BASE 0x4E000000
#define NFCONF_OFFSET 0x0
#define NFCONT_OFFSET 0x4
 
nand_asm_init:
ldr r0, =S3C2440_NAND_BASE
     ldr r1, =0x001210
str r1, [r0, #NFCONF_OFFSET]
 
     mov r1, #0x3
str r1, [r0, #NFCONT_OFFSET]
 
     mov pc, lr
/*end_of nand_asm_init*/
 
mem_ctrl_asm_init:
    @ Set up the memory controller to use peripherals such as SDRAM
 
    mov r1, #MEM_CTL_BASE @ The starting address of the 13 registers of the storage controller
    adrl r2, mem_cfg_val @ The starting storage address of these 13 values
    add r3, r1, #52 @ 13*4 = 54
1:  
    ldr r4, [r2], #4 @ Read the setting value and add 4 to r2
    str r4, [r1], #4 @ Write this value to the register and add 4 to r1
    cmp r1, r3 @ Determine whether all 13 registers have been set
    bne 1b @ If not written, continue
    mov pc, lr @ return
 
 
.align 4
mem_cfg_val:
    @ Storage controller 13 register settings
    .long 0x22011110 @ BWSCON
    .long 0x00000700 @BANKCON0
    .long 0x00000700@BANKCON1
    .long 0x00000700 @BANKCON2
    .long 0x00000700 @BANKCON3  
    .long 0x00000700 @BANKCON4
    .long 0x00000700 @BANKCON5
    .long 0x00018005@BANKCON6
    .long 0x00018005@BANKCON7
    .long 0x008C07A3 @ REFRESH
    .long 0x000000B1@BANKSIZE
    .long 0x00000030 @ MRSRB6
    .long 0x00000030 @ MRSRB7
 
After starting up, it will jump to main. I won't say much about the LCD parameters. I have used RVDS before and there is no problem. Many blogs and textbooks explain it very clearly. Here I will mainly write about the implementation process.
Debug screenshots:
Eclipse development and debugging of ARM bare metal programs (Part 7) LCD
 
 
 
Display screenshot:
Eclipse development and debugging of ARM bare metal programs (Part 7) LCD
 
 
Code: http://download.csdn.net/detail/kangear/5268137
Keywords:Eclipse Reference address:Eclipse development and debugging of ARM bare metal programs (Part 7) LCD

Previous article:Eclipse development and debugging of ARM bare metal programs (Part 7) SD card reading and writing
Next article:Developing and debugging ARM bare metal programs in Eclipse (V) MMU debugging

Recommended ReadingLatest update time:2024-11-16 19:58

Multi-parameter measurement system of solar cell modules based on ARM
1. Introduction When generating electricity, solar cell modules do not convert all the light energy they receive into electrical energy, but only a small part of it. Most of the energy evaporates in the form of heat energy on the back panel of the solar cell module. At the same time, the volatilization of hea
[Microcontroller]
Multi-parameter measurement system of solar cell modules based on ARM
Introduction to the principle and program implementation of LPC2100 series encryption ARM chips
1. Encryption principle description The LPC2100 series ARM7 microcontroller is the world's first ARM chip that can be encrypted. The method of encrypting it is to set the specified data at the specified address through the user program. PHILIPS stipulates that for the LPC2100 chip (except LPC2106/2105
[Microcontroller]
Developing ARM-based embedded systems with GNU tools
This article introduces how to use GNU tools to develop ARM -based embedded systems, as well as specific methods for using compilers, connectors and debugging tools, to provide a low-cost development method for the majority of embedded system developers. At present, ARM's 32-bit RISC proce
[Microcontroller]
Developing ARM-based embedded systems with GNU tools
New driver technology helps reduce power consumption of LCD TVs
The results of the SEAD project show that TVs account for about 3% to 8% of global household electricity consumption. Analysis by the Lawrence Berkeley National Laboratory in the United States shows that in the next few years, advances in TV technology (such as improved LED drive efficiency) will help significantly red
[Power Management]
New driver technology helps reduce power consumption of LCD TVs
Understanding the Arm China "leadership change" storm in one article
      In 2020, the technology circle has seen one "drama" after another. This time, it was the turn of Arm, the world's leading semiconductor intellectual property (IP) manufacturer, and Arm China's joint venture, Arm Technology (hereinafter referred to as Arm China). The two sides staged a drama of "the board of dire
[Mobile phone portable]
Understanding the Arm China
Design of circuit module of fingerprint attendance system based on ARM7
  The attendance system has now become a must-have equipment for many companies, but the traditional attendance system is prone to replacing punching and swiping cards. The new fingerprint attendance machine completely avoids this situation. This article introduces a solution for designing a fingerprint attendance mac
[Microcontroller]
Design of circuit module of fingerprint attendance system based on ARM7
LCD1602 Liquid Crystal Display Module In-depth Explanation of Software (AVR)
Although the driver of LCD1602 liquid crystal display module is more complicated than the display of seven-segment digital tube, it is not very difficult in fact. The most important thing is initialization. Why do we say that? When we debug a new LCD screen, we will initialize it first to see if there is a cursor flas
[Microcontroller]
LCD1602 Liquid Crystal Display Module In-depth Explanation of Software (AVR)
Design and implementation of smart home control communication control station based on ARM
0 Preface Object informatization is the "catalyst" and "multiplier" of the informatization construction of modern society. Only by integrating information technology and information data can the informatization construction of enterprises really play a role and further promote the level of information construction. Th
[Microcontroller]
Design and implementation of smart home control communication control station based on ARM
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号