当前位置:网站首页>三星6818基于uboot的流水灯程序
三星6818基于uboot的流水灯程序
2022-07-21 17:26:00 【I&You】
三星6818uboot的亮灯程序
查阅芯片资料获取寄存器信息
- 查看文档目录查找到gpio功能相应模块
- 找到配置gpio的方法
- 找到对应的寄存器配置地址
1)这个是我们要用到的寄存器图表
2)这个是gpio复用功能寄存器,由两位比特位还选择不同的复用功能,至于功能0~3分别是什么还需查相关资料这里就不多解释了
3)这是我们的输出输入使能寄存器
4)这是我们要输出高低电平的寄存器
5)还要参考原理图
编写源码
有了资料和配置方法,现在我们附上源码让D7灯亮起来~~
//1.定义寄存器
#define GPIOEOUT (*(volatile unsigned int *)0xC001E000)
#define GPIOEOUTENB (*(volatile unsigned int *)0xC001E004)
#define GPIOEOUTALTFN0 (*(volatile unsigned int *)0xC001E020)
#define GPIOEOUTALTFN1 (*(volatile unsigned int *)0xC001E024)
static void delay(void);
//2.c程序的入口,同时不使用标准的c库,因此入口函数名字为_start
void _start(void)
{
//配置GPIOE13为输出模式
GPIOEOUTALTFN0&=~(3<<26); //GPIOE13的多功能配置[27:26]清零
//允许GPIOE13输出电平
GPIOEOUTENB|=1<<13;
while(1)
{
//点亮
GPIOEOUT&=~(1<<13);
//延时一会
delay();
//熄灭
GPIOEOUT|=1<<13;
//延时一会
delay();
}
}
void delay(void)
{
//思考为什么要加volatile
volatile unsigned int i=0x2000000;
while(i--);
}
- 写完代码之后,我们就来编译,因为我们这个程序要在开发板运行,所以要用板子的交叉编译工具编译用gcc是不行的
1.检查ubuntu是否有交叉编译器。
[email protected]:~$ which arm-linux-gcc
/usr/local/arm/5.4.0/usr/bin/arm-linux-gcc
2.进入共享目录去编译led_demo1裸机程序。
1)将led.c编译为目标文件led.o,且不使用标准c的库
arm-linux-gcc -o led.o -c led.c -nostdlib
2)将led.o链接到内存地址0x40000000,输出新的执行程序为led.elf
arm-linux-ld -Ttext 0x40000000 -o led.elf led.o
3)由于uboot不是linux操作系统,它不具有运行应用程序的能力,需要转换为bin文件。
arm-linux-objcopy -O binary led.elf led.bin
- 完了之后呢我们用tftp把led.bin下载到uboot(开发板开机后用SecureCRT工具5秒内按任意键进入uboot,然后用ifconfig 192.168.1.110和setenv serverip 192.168.11.3命令修改你ip地址和服务器地址,知道你在开发板能用ping命令ping你电脑成功为止)
#tftp 文件名 内存地址
#tftp led.bin 0x40000000
//这里电脑端要用到个tftp工具可以找我拿(SecureCRT工具也可找我),微信:a812417530
- 执行某地址存在的二进制文件
#go 内存地址
#go 0x40000000
##Starting application at 0x40000000 ...
- 结果
边栏推荐
- Windows环境下Redis安装与配置的两种方式
- 十年交易员重磅推荐:简单易操作的突破回调策略
- Differences between runtime+compiler and runtime only versions
- 指针深度解刨《四》(指针和数组的 “亲密“ 关系)
- Zhang Chi Consulting: How Six Sigma can help companies reduce customer complaints
- RPA是什么?推荐让电商运营10倍提效的自动化工具
- v-7
- 指针深度解刨《二》(指针指向自己)
- Self study golang [Chapter 1: basic knowledge of go language] Why do you want to learn go language? The relationship between go language and C language? Founder of go language? What are the characteri
- 量化交易中通过均线系统判断上涨(下跌)动能减弱
猜你喜欢
In quantitative trading, it is judged by the moving average system that the upward (downward) momentum is weakened
文件操作《二》(5000字总结篇)
Science and technology create value | cloud expansion technology is listed in the real list · top 100 of China's scientific and technological innovation brands list
不断提升认知,从而达到交易的最高级别——稳定盈利(一)
Windows环境下Redis安装与配置的两种方式
v-7
Self study golang [Chapter 3: the first go language program] use GoLand to create the first go program, the main function and init function, and use go to run Windows commands and realize the data out
How to build a smart park with 5g and mobile edge computing servers
指针总结篇
v-7
随机推荐
Self study golang [3.3go language loop statement] for loop syntax structure, omit initial conditions, omit incremental conditions, omit the application of end conditions
How to open an account for agricultural futures? Who can open Everbright futures?
Cannot read property ‘type‘ of undefined Occurred while linting **\index.jsx:1
Differences between runtime+compiler and runtime only versions
C#异常处理 | 连接成功但登陆异常/管道另一端上无任何进程Error: A connection was successfully established with the server, but
量化交易中如何判断趋势
JS时间和时间戳的转换
How to build a smart park with 5g and mobile edge computing servers
How does pytorch convert a variable or tensor to numpy?
Soft exam intermediate [Database System Engineer] Chapter 1: computer system knowledge, self-study soft exam notes, preparation for the soft exam in May 2022, computer hardware system CPU composition
RunTime+compiler和RunTime only版本的区别
Experimental support for decorators is a feature that is subject to change in a future release. Set
Self study the definition of golang [3.5go language array, range keyword] array, and use the for loop to traverse one-dimensional array
[step on pit] solution to NPM installation error
Verilog -- 74hc194 multifunctional bidirectional shift register
量化交易中的三类行情
Excel中时间戳和时间的转换
软考中级【数据库系统工程师】第1章:计算机系统知识,自学软考笔记,备考2022年5月份软考,计算机硬件系统CPU组成指令寄存器组总线输入输出的程序控制方式计算机体系结构与存储系统加密技术流水线技术
What is RPA? Recommend automated tools that allow e-commerce operators to operate 10 times more efficiently
指针的深度解刨《五》