当前位置:网站首页>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下载工具软件会自动将其设置为自动追频模式。下载界面如下:
边栏推荐
- 毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
- 【AI服务器搭建】CUDA环境
- 安装sharp报错
- Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
- 类加载机制
- 有意思了!数据库也搞Serverless!
- Opencv video quality detection -- sharpness detection
- mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- 今日群里分享的面试题
- GC垃圾回收
猜你喜欢

解决VSCode下载慢或下载失败的问题

简单但现代的服务器仪表板Dashdot

Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road

GC垃圾回收

SQL getting started plan-1-select
![[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached

Bind this of the current scope for callback functions in other cases such as timers and delayers

EasyCVR集群视频广场页面切换时,请求流未能终止的问题优化

安装sharp报错

类加载机制
随机推荐
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Compile ffmpeg source code with msys+vs2019 under win10
After studying 11 kinds of real-time chat software, I found that they all have these functions
PowerDesigner design name and comment replacement
Process steps of vibrating wire acquisition module for measuring vibrating wire sensor
Basic use of MySQL
torch. nn. functional. Interpolate function
一个悄然崛起的国产软件,低调又强大!
科技T3国产平台!成功搭载“翼辉国产实时系统SylixOS”
Regular expression =regex=regular expression
How to add transactions in JDBC
Optaplanner learning notes (I) case cloud balance
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
Proxy in ES6
Actual combat of flutter - fast implementation of audio and video call application
【无标题】
How to configure webrtc video streaming format for easygbs, a new version of national standard gb28181 video platform?
对象的创建
mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
[research materials] national second-hand housing market monthly report January 2022 - Download attached