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(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.
Previous article:ARM and Flash ROM
Next article:LCD character display of s3c2440
Recommended ReadingLatest update time:2024-11-16 14:33
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Qinheng Trial] CH559EVT Trial 3: Flowing Water Light
- ST MEMS Device Resource Library - State Machine (FSM) and Machine Learning (MLC) Functions [LSM6DSOX]
- [Analog Electronics Course Selection Test] + Basic Knowledge of Operational Amplifiers
- [Repost] Useful information: One article teaches you how to understand inductors
- max30003 driver
- Smart Bluetooth Technology Principle
- TMS320F28027
- STM32 adc dma mode continuous conversion invalid reason
- Use serial port tools and serial port assistants to monitor the communication process between the mainboard MCU and the Bluetooth module--
- [SAMR21 New Gameplay] 20. Analog Input and Analog Output