当前位置:网站首页>STC 32位8051单片机开发实例教程 三 程序编译设置与下载
STC 32位8051单片机开发实例教程 三 程序编译设置与下载
2022-07-01 18:47:00 【Bill66】
下面是一端程序STC32G的程序源代码:
/*main.c
Designed by Bill Liu
Version 0.0
Modified last by Bill Liu on 06/22/2022
*/
#include "main.h"
#include "config.h"
void main()
{
STC32G_P7PinsInit(PIN3, BI_IO, 0, 0, 0, 0, 1, 1);
//P73 = 0;
STC32G_P0PinsInit(0xFF, BI_IO, 1, 0, 0, 0, 1, 1); //init to bidirectional I/O, pull up disable, pull down disable , dive ability enhance disable,
//high speed disable, digital singal input enable, schmitt trigger enable
STC32G_P2PinsInit(0xFF, BI_IO, 0, 0, 0, 0, 1, 1);
P0 = 0xAA;
P2 = 0xFF;
//P73 = 0;
while(1)
{
if(P2 == P0)
P73 = 0;
else
P73 = 1;
}
}
//End of main()Keil C251的Target项的设置如下:

L251 Misc的设置如下:

编译上面的程序,结果如下:

修改Keil C251的Target项的设置如下:

编译同一程序,结果如下:

出现了4个Warnings. 再将修改Keil C251的Target项的设置修改,如下:

编译同一程序,结果如下:

无Warning。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:

无Warning。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:

无Warning。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:

无Warning。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:

无Warning。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:
出现错误。再修改Keil C251的Target项的设置,如下:

编译同一程序,结果如下:

编译成功,无Warning。
从上面的示例可以看出,同一程序,选用不同的设置,在优化等级不做调整的情况下,编译后的程序code大小是不一样的。选用有些可能还会编译出错。
现在用下面的设置编译改程序:

编译结果如下:

将编译后的得到的hex文件,下载 到单片机,正常情况红色LED应该亮起。下载后的结果如下:

红色LED确实亮起,说明程序没问题。再改变Keil C251的Target项的设置,如下:

编译程序,结果如下:
编译通过,没有Warning。将编译后的得到的hex文件,下载 到单片机,正常情况红色LED应该亮起。下载后的结果如下:

红色LED并未亮起。说明改设置编译得到的程序,不能正常运行。
STC 32G系列单片机依然可以像STC 8位 8051单片机一样通过用ch340 USB转串口模块实现ISP下载程序。我的下载工具如下:

一般情况下,不用理会STC 32G单片机的时钟设置,在下载时选择需要的工作频率即可STC_ISP下载工具软件会自动将其设置为自动追频模式。下载界面如下:
边栏推荐
- 有意思了!数据库也搞Serverless!
- 2022/6/8-2022/6/12
- Audio and video, encoding and decoding related e-books, gadgets, packaged for free!
- DS Transunet:用于医学图像分割的双Swin-Transformer U-Net
- Difference between redo and undo
- Linux下安装Redis,并配置环境
- 【let var const】
- Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
- Remove line breaks from MySQL query results
- 对金额进行求和
猜你喜欢

Why must we move from Devops to bizdevops?
![[research materials] national second-hand housing market monthly report January 2022 - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] national second-hand housing market monthly report January 2022 - Download attached

servlet知识点

ModSim基本使用(Modbus模拟器)

安装sharp报错
![P2433 [deep foundation 1-2] primary school mathematics n in one](/img/28/e5eab8927694ea002b536202a1b5ea.png)
P2433 [deep foundation 1-2] primary school mathematics n in one

一个悄然崛起的国产软件,低调又强大!
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

为定时器和延时器等其它情况的回调函数绑定当前作用域的this

Uni app wechat applet one click login to obtain permission function
随机推荐
Cookie和Session的相关概念
[untitled]
Crunch简介、安装,使用Crunch制作密码字典
全国职业院校技能大赛网络安全“splunk“详细配置
JS 之 常用内置类的使用
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Axure does not display catalogs
振弦采集模塊測量振弦傳感器的流程步驟
Botu V16 obtains the system time and converts it into a string
Ffmpeg audio related commands
Salesmartly has some tricks for Facebook chat!
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached
Time series analysis using kibana timelion
Unreal Engine packaging project
自定义插入页面标签以及实现类似通讯录的首字母搜索
Opencv video quality detection -- sharpness detection
实例讲解将Graph Explorer搬上JupyterLab
Using win7 vulnerability to crack the system login password
Interview question 16.16 Partial sorting - Double finger needling
Shell advanced