当前位置:网站首页>ARM development (4) How to read the chip manual for novice Xiaobai, bare metal driver development steps and pure assembly to achieve lighting, assembly combined with c lighting, c to achieve lighting
ARM development (4) How to read the chip manual for novice Xiaobai, bare metal driver development steps and pure assembly to achieve lighting, assembly combined with c lighting, c to achieve lighting
2022-08-11 01:56:00 【fly to】
一.How to read the chip manual(datasheet)
as an embedded learner,How to read the chip manual is the top priority.No matter what the chip manual,How hype is written,Its essence is the instruction manual.
可是问题来了,它YThis is the manual in English,But friends who are not good at English should not be too anxious,We now have good translation software,And as long as we read more and read more,Accumulate at a point in the future,Reading the chip manual is no longer a problem for you.
Next, I will use a Samsung chip manual in a vivid image to lead you to read the chip manual together with how to carry out simple driver development,Learn how powerful it is.
二.Bare metal driver development steps
1.When we get a board,If you want to achieve specific functions,The first thing we must think about is to understand what kind of function we want to achieve.(Here, I will take the lighting of lamps that students are annoying to see as an example)
2.Now that we understand that our goal is to light up the lights,Then all we have to do next is find the little light bulb on the board(发光二极管)
如图:
然后我们看到了led【2-5】There are four small bulbs in total
After finding the small light bulb and the name, we officially opened the road to lighting our lights.
Bare metal driver development
(1)看电路图
--1.Find the device I want to control(Take the small light bulb hereled2来举例)
Open our peripheral hardware manual and search in the search barled2
如图
We know from this picture,这是一个npn三极管,The base is connectedcpuside control pinsCHG_COK,由cpuTo perform analog-to-digital conversion to control the high and low potentials,Determines the turn-on and turn-off of the transistor.Here we ignore the already marked onesGPX2_7.
(2)看芯片手册
搜索,The corresponding control module in the circuit diagram,然后如果有coreboardIf so, go there to find the corresponding oneGPX2-7.
看模块的overviewLearn about the approximate functionality of this module.
(3)Look at the control register
What should we do if there are more registers?
See sample programs provided by Technical Support,Find the register that needs to be modified(Often there are only a few).
Some manufacturers provide configuration software,Configure functions through the interface,We just need to use the value of the configured register.
Come to the chip manual,如图所示:
(4)编程
1.A macro that defines the register to be controlled(Corresponds to the register address in the manual)
2.设备初始化(如设置GPIO的输出状态) tips:GPIO就是与cpu相连的引脚
3.Break the functionality into the most basic pieces,逐个实现,如:点亮灯——灭灯——加延时——闪烁——跑马灯
The following code is in thiscpuand implemented on the development board:
cpu:samsung Exynos
开发板: FS4412
三.Pure assembly to achieve lighting
@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] while: ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay_1s ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay_1s b while delay_1s: ldr r10, =0x4ffffff loop: cmp r10, #0 subgt r10, #1 bgt loop mov pc, lr .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(LD) start.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
四. assemblyc点灯
mian.c 实现延时
> Created Time: 2022年08月10日 星期三 15时43分06秒 ***********************************************************************/ void delay() { int i, j; for(i = 0; i < 10000; i++) for(j = 0; j < 256; j++); } /*******************************end of file*****************************/@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] while: ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay @ 调用main.c中的delay函数,进行延时 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay @ 调用main.c中的delay函数,进行延时 b while .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(CC) -c main.c $(CROSS)$(LD) start.o main.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
五.c实现点灯,This method is what we use the most,Also the easiest
main.c
***********************************************************************/ void delay() { int i, j; for(i = 0; i < 10000; i++) for(j = 0; j < 256; j++); } #define GPX2CON *(volatile unsigned int *)0x11000c40 #define GPX2DAT *(volatile unsigned int *)0x11000c44 void led2_init() { // GPX2CON = GPX2CON & 0x0fffffff | (1 << 28) GPX2CON = GPX2CON & (~(0xf << 28)) | ( 0x1 << 28 ); } void led2_on() { GPX2DAT = GPX2DAT | (1 << 7); } void led2_off() { GPX2DAT = GPX2DAT & (~(1 << 7)); } int main() { led2_init(); while(1){ led2_on(); delay(); led2_off(); delay(); } } /*******************************end of file*****************************/.text b main .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(CC) -c main.c $(CROSS)$(LD) start.o main.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
六.Pure assembly to achieve marquee
@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0,=0x11000c20 ldr r1,[r0] bic r1,#0xf orr r1,#0x1 str r1,[r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] ldr r0,=0x114001E0 ldr r1,[r0] bic r1,#0xf00000 orr r1,#0x100000 str r1,[r0] while: @开灯led2 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] bl delay_1s @开灯led3 ldr r2,=0x11000c24 ldr r3,[r2] orr r3,#0x1 str r3,[r2] bl delay_1s @开灯led4 ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay_1s @开灯led5 ldr r2,=0x114001E4 ldr r3,[r2] orr r3,#0x20 str r3,[r2] bl delay_1s @关灯led2 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] bl delay_1s @关灯led3 ldr r2,=0x11000c24 ldr r3,[r2] bic r3,#0x1 str r3,[r2] bl delay_1s @关灯led4 ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay_1s @关灯led5 ldr r2,=0x114001E4 ldr r3,[r2] bic r3,#0x20 str r3,[r2] bl delay_1s b while delay_1s: ldr r10, =0x4ffffff loop: cmp r10, #0 subgt r10, #1 bgt loop mov pc, lr .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(LD) start.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
边栏推荐
- MySQL八股文背诵版(续)
- leetcode 739. Daily Temperatures 每日温度(中等)
- 【oops-framework】模板项目【oops-game-kit】使用简介
- 想进阿里?先来搞懂一下分布式事务
- Successfully resolved TypeError: can't multiply sequence by non-int of type 'float'
- 进程间通信方式(1)无名管道(全CSDN最用心的博主)
- 导入数据包上传宝贝提示“类目不能为空”是什么原因,怎么解决?
- [Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash
- 迭代器和生成器
- 一次简单的 JVM 调优,拿去写到简历里
猜你喜欢

22、库存服务

MySQL八股文背诵版(续)

MySQL indexes and transactions

两日总结十

HCIP-R&S By Wakin自用笔记(3)OSPF之引入外部路由、Forwarding-Address、汇总、特殊区域

请讲一讲JS中的 for...in 与 for...of (下)
![[Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash](/img/dc/043f861507fc16530446bf051941ef.jpg)
[Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash

QT+VTK+PCL拟合圆柱并计算起始点、中止点

MySQL基础篇【第一篇】| 数据库概述及数据准备、常用命令、查看表结构步骤

【Video】Report Sharing | 2021 Insurance Industry Digital Insights
随机推荐
MySQL - 一条SQL在MySQL中是如何被执行的?
This Thursday evening at 19:00, Lesson 5 of the sixth phase of knowledge empowerment丨OpenHarmony WiFi subsystem
软件测试面试题:软件测试的过程的V模型,说出它的缺点?
软件测试面试题:缺陷等级应如何划分?
阿里的数据同步神器——Canal
[The method of calling the child page from the parent page of the iframe] Stepping on the pit: It is the key to use `[x]` when getting elements. You cannot use `.eq(x)`, otherwise it will not be obtai
C# WebBrower1控件可编辑模式保存时会提示“该文档已被修改,是否保存修改结果”
php 判断数组是否为多维数组
ora-00001违反唯一约束
进程间通信方式(1)无名管道(全CSDN最用心的博主)
进程间通信(IPC)的分类以及通信方式的发展
3342:字符串操作 题解
loop word
nvidia-smi:控制你的 GPU
sql 使用到where和groupby时到底怎么建立索引?
软件测试面试题:Web服务器指标指标?
C# string与stream的相互转换
Still using Xshell?You are out, recommend a more modern terminal connection tool, easy to use!
基于 HPSO 与多核 LSSVM 的网络入侵检测
想进阿里?先来搞懂一下分布式事务


