ARM bare metal program - Marquee

Publisher:莫愁前路Latest update time:2016-08-14 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I recently read some boot code analysis, and there are still many things I don't understand. I plan to write about boot code analysis later. I first ran some bare metal programs without an operating system to familiarize myself with the hardware. The development board used is FL2440.

Let's look at this piece of C code first

#define GPBCON (*(volatile unsigned long *)0x56000010) //This is the definition of the register. Since the GPB pin is connected to the LED in hardware, if the GPB pin is used, then the relevant register must be defined. This register defines the working mode of the GPB related pin.
#define GPBDAT (*(volatile unsigned long *)0x56000014) //This register is used to give data to the pin.

int main()
{
 GPBCON=0x00000400;
 GPBDAT=0x00000000;
 
 return 0;

}

This is a complete marquee program. GPBUP is the pull-up enable register. When using the pin, it is generally defined as enable invalid.

The address declaration at the beginning of the program can be defined later as #include "2440addr.h". The 2440addr.h file contains the definitions of all register addresses in arm.


/* Address declaration */
#define GPBCON (*(volatile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
#define GPBUP (*(volatile unsigned long *)0x56000018)


/* Variable declaration */ 
#define uint unsigned int

#define LED0_ON() (GPBDAT &= ~(1<<5))
#define LED1_ON() (GPBDAT &= ~(1<<6))
#define LED2_ON() (GPBDAT &= ~(1<<8) )
#define LED3_ON() (GPBDAT &= ~(1<<10))

#define LED0_OFF() (GPBDAT |= (1<<5))
#define LED1_OFF() (GPBDAT |= (1<<6))
#define LED2_OFF() (GPBDAT |= (1<<8))
#define LED3_OFF() (GPBDAT |= (1<<10))

/* Function declaration */ 
void Delay(uint);

 

/* Delay function */
void Delay(uint x)
{
 uint i,j,k;
 for(i=0;i   for(j=0;j<0xff;j++)
   for(k=0;k<0xff;k++);

/* Main function */
int Main(void)
{
 GPBCON = (1<<(5*2)) | (1<<(6*2)) | (1<<(8*2)) | (1<<(10*2));//Set the relevant pins of LED0, LED1, LED2 and LED3 to output
 GPBUP = 0xff;
 GPBDAT = (1<<5)| (1<<6) | (1<<8)| (1<<10);
 
 
 while(1)
 {
  LED0_ON();
  Delay(30);
  LED0_OFF();
  LED1_ON();
     Delay(30);
  LED1_OFF();
  LED2_ON();
     Delay(30);
  LED2_OFF();
  LED3_ON();
  Delay(30);
  LED3_OFF();
  Delay(30);
 }
 return 0;
}

There are some software configuration issues here, which I won't mention. Also, the startup code I used cancelled all MMU related content because it is not used in bare metal programs.
Keywords:ARM Reference address:ARM bare metal program - Marquee

Previous article:ARM and Flash ROM
Next article:LCD character display of s3c2440

Recommended ReadingLatest update time:2024-11-16 14:33

ARM cortex-M4 jtag read dp and ap registers example interpretation
https://www.linmingjie.cn/index.php/archives/253/ DDI0413C_cortexm1_r0p1_trm.pdf // https://developer.arm.com/documentation/ddi0413/c/Babeagge stm32f407zg development board // any card like this will do dsview package (logic analyzer) jlink for windows software jlink (usb to jtag) Because there is no suitable inform
[Microcontroller]
ARM coprocessor CP15 settings MMU, cache, etc.
I have always been afraid of the coprocessor CP15 because I can hardly find detailed descriptions in Chinese on the Internet. Now I have found some official ARM documents (ARM920T Technical Reference Manual) and I am ready to put it to rest.     Coprocessor CP15 contains the following registers. ================
[Microcontroller]
Implementation of GSM Remote Monitoring System Based on ARM
  1 Introduction   At present, vehicle information systems have gradually become an indispensable part of intelligent transportation systems (ITS) that integrate advanced electronic, computer and communication technologies.   The in-vehicle information system integrates multiple information services such as vehicle
[Microcontroller]
Implementation of GSM Remote Monitoring System Based on ARM
Will the 51% Chinese shareholder of ARM Technology sell its shares? The company responded that it has not received any information or contacted
As the new management team of Arm Technology gradually takes over the business and external publicity channels, new variables seem to have emerged.    On May 18, a press release began to circulate on the Internet. The press release stated that Lianxin Fund, a subsidiary of Lianxin Group, had reached an agreement with
[Semiconductor design/manufacturing]
Will the 51% Chinese shareholder of ARM Technology sell its shares? The company responded that it has not received any information or contacted
Design of smart home remote monitoring system based on ARM
With the rapid development of computer, communication and microelectronic technology and the improvement of people's living standards, people's requirements for living environment are also moving towards the ideal goal of pursuing spiritual connotation, safety and comfort, convenience, intelligence and automation. Inte
[Microcontroller]
Design of smart home remote monitoring system based on ARM
ARM7 memory structure and external flash
1. Words and Halfwords of Memory 1. Two consecutive bytes starting from an even address constitute a half-word. 2. Four consecutive word orders of addresses divisible by 4 constitute a word The length of an ARM instruction is exactly one word, and the length of a Thumb instruction is exactly one half word. 2.
[Microcontroller]
In-depth understanding of ARM architecture basics
To switch from MCU to ARM, you need to learn the ARM architecture. ARM has more peripherals and buses than MCU. If you are familiar with the ARM architecture, I think there will be no difference between using any ARM architecture chip and using MCU. The reason why ARM architecture is more complex is, of course, to run
[Microcontroller]
In-depth understanding of ARM architecture basics
Targeting Intel! Arm CEO makes a ruthless statement: Take 50% of Windows PC market share within 5 years
On June 4, Arm CEO Rene Haas made a bold statement in an interview that he would capture 50% of the Windows PC market share within five years. With its open ecosystem and architectural advantages, Arm has become the most successful architecture in the past decade, achieving high performance and high efficiency
[Home Electronics]
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号