当前位置:网站首页>ARM Architecture 4: Embedded Hardware Platform Interface Development
ARM Architecture 4: Embedded Hardware Platform Interface Development
2022-08-11 05:17:00 【Lost your】
Here the blogger uses cortex_A9 as an example: the following is a picture introduction of the development board I use:
The components and interfaces in the development board are marked in detail in the figure. Below, I will briefly introduce a basic process of bare metal development using the development board by lighting the LED.
1. Look at the circuit diagram
First we need to find the device we need to operate in the circuit diagram of the provided development board data.And understand the principle of its operation. For example, we want to light up the LED lights on the development board. First, we find its circuit schematic diagram in the provided development board information as follows:
Let's analyze the following. To make our light-emitting diode turn on, our corresponding pin needs to provide a high level to the base of the triode, so that the diode can be turned on and the led will be lit.A resistor protects our chip and LED respectively.The transistor type is NPN.
2. Look at the chip manual
Then we find the corresponding control module in the chip schematic book. The control pins of the LED light such as GPX2_7, as shown below
You can see that the data provides us with information such as the starting address of the register. We need the chip to output a high level, then we need to select the mode as the OUTput output mode, then this is what we will do next!Look at the control register.
3. Programming
a. Define the macro of the register we want to control (corresponding to the register address in the manual)
b. Device initialization.(For example, in the operation of lighting up the LED, we need to set it to the output state, that is, set the 31-28 bits to 0x01)
c. Divide the function into the most basic small pieces. For example, if we want to realize the sequential lighting and extinguishing of LED lights, then we need to turn on the lights first, then turn off the lights, add delay, and flicker. Finally, we have completed aThe function of the marquee.
Then we show two pieces of code to show the operation of lighting the lamp, one is the assembly instruction used, and the other is implemented using our C language. In general bare metal development, we generally use the C language.
The lighting of the assembly instruction completion light:
@GPX2CON Register address: 0x11000000+0x0c40.textldr r0,=0x11000c40 @Move the register address to R0, then R0 represents GPX2CONldr r1,[r0]bic r1,#0xf0000000 @Clear bits 28-31orr r1,#0x10000000 @Set bit 28 to 1, other bits remain unchanged, set the output function of GPX2_7str r1,[r0]ldr r0,=0x114001e0 @Move the GPF3C0N register to R0ldr r1,[r0]bic r1,#0xf0000 @Clear bits 19-16orr r1,#0x10000 @Set bit 16 to 1, other bits remain unchanged, set GPX3-4 as output functionstr r1,[r0]@Light upwhile:ldr r2,=0x11000c44 @Move the register address of the register GPX2DAT to R2ldr r3,[r2]orr r3, #0x80 @set the 7th position of GPX2DAT to 1str r3,[r2]ldr r2,=0x114001e4ldr r3,[r2]orr r3,#0x10 @Set the 4th position of GPX3DAT to 1str r3,[r2]bl [email protected] offldr r2,=0x11000c44ldr r3,[r2]bic r3, #0x80str r3,[r2]ldr r2,=0x114001e4ldr r3,[r2]bic r3, #0x10str r3,[r2]bl delay_1msb whiledelay_1ms:ldr r5,=0x4fff0000loop:cmp r5,#0subgt r5,#1bgt loopmov pc,lr.end
C language:
#define GPX2CON *(volatile unsigned int*)0x11000c40#define GPX2DAT *(volatile unsigned int*)0x11000c44void led2_init(){GPX2CON =GPX2CON &(~(0xf<<28))|(1<<28);}void led2_on(){GPX2DAT=GPX2DAT|(1<<7);}void led2_off(){GPX2DAT=GPX2DAT &(~(1<<7));}void delay(){int i,j;for(i=0;i<10000;i++)for(j=0;j<256;j++);}int main(){led2_init();while(1){led2_on();delay();led2_off();delay();}}
The point is to find the corresponding module, pay attention to the control register, and realize our function by modifying the control register.
边栏推荐
- 面试题整理
- leetcode 9. Palindromic Numbers
- -Fill in color-
- 论文笔记:BBN: Bilateral-Branch Network with Cumulative Learningfor Long-Tailed Visual Recognition
- 用白嫖的Adobe正版软件,减少应届毕业生的慢就业、不就业等现象
- 交换机和路由器技术-24-OSPF单区域配置
- 交换机和路由器技术-28-OSPF的NSSA区域
- ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx
- 论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
- Delphi7学习记录-demo实例
猜你喜欢
网络协议1
Switches and routers technology - 21 - RIP routing protocol
交换机和路由器技术-26-OSPF末梢区域配置
Switch and Router Technology - 32 - Named ACL
Internet Protocol 1
ESP8266 教程3 — 通过TCP组建局域网并通信
C statement: data storage
交换机和路由器技术-24-OSPF单区域配置
交换机和路由器技术-35-NAT转PAT
HAVE FUN | "SOFA Planet" spacecraft plan, the latest progress of source code analysis activities
随机推荐
guava RateLimiter均匀限流
Zabbix builds enterprise-level monitoring and alarm platform
每周推荐短视频:你常用的拍立淘,它的前身原来是这样的!
Unity WebGL RuntimeError: integer overflow(整数溢出问题)
四大函数式接口
02. Fold hidden text
交换机和路由器技术-36-端口镜像
交换机和路由器技术-21-RIP路由协议
K8s Review Notes 7--K8S Implementation of Redis Standalone and Redis-cluster
Research on a Consensus Mechanism-Based Anti-Runaway Scheme for Digital Trunking Terminals
leetcode 9. Palindromic Numbers
paddlepaddle实现CS_CE Loss且并入PaddleClas
BitLocker的解密
MySQL数据库管理
MySQL事务的概念
如何阅读论文
@Resource和@Autowired的区别
交换机和路由器技术-34-动态NAT
svg-icon的使用方法(svg-sprite-loader插件)
prometheus:(二)监控概述(你永远逃不出我的手掌哈哈)