DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 3219|回复: 6
打印 上一主题 下一主题

[求助] 有懂c编译的朋友吗?这个c程序用Keil 编译不通过

[复制链接]
跳转到指定楼层
楼主
发表于 2023-4-24 15:34:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
有懂c编译的朋友吗?这个c程序用Keil 编译不通过,帮忙给看看是哪里的问题.

// 8051初始源程序
//
#include <sfr.h>
#include <os.h>
#include <stdlib.h>
#include <stdio.h>
_sfrbit P36_o_74f161_clr_n = _p3^6; //
_sfrbit P35_o_74f161_enp = _p3^5; //外部计数器F161有效(Enable)
_sfrbit P30_io_74hc393_clr_hold = _p3^0;  //外部计数器HC393复位/HOLD输入
_sfrbit P37_i_prescaler = _p3^7; // 64分频的预分频器
//
//七段LED字形数据
// hgfedcba
#define DIG0 0xC0 // 11000000b ; 0 P2.0
#define DIG1 0xF9 // 11111001b ; 1 +-----a-----+
#define DIG2 0xA4 // 10100100b ; 2 | |
#define DIG3 0xB0 // 10110000b ; 3 P2.5 f b P2.1
#define DIG4 0x99 // 10011001b ; 4 | |
#define DIG5 0x92 // 10010010b ; 5 | P2.6 |
#define DIG6 0x82 // 10000010b ; 6 +-----g-----+
#define DIG7 0xD8 // 11011000b ; 7 | |
#define DIG8 0x80 // 10000000b ; 8 P2.4 e c P2.2
#define DIG9 0x98 // 10011000b ; 9 | |
// ; | P2.3 |
#define DIGM 0xBF // 10111111b ; - +-----d-----+ * h P2.7
#define DIGP 0x7F // 01111111b ; .
#define DIGB 0xFF // 11111111b ; "Blank"(“空白”)
//
const char segment_pattern[] = { DIG0, DIG1, DIG2,\
DIG3, DIG4, DIG5, DIG6, DIG7, DIG8, DIG9 };
//
const char segment_select[] = { 0xFE, 0xFD, 0xFB, \
0xF7, 0xEF, 0xDF, 0xBF, 0x7F };
//
unsigned long trailer;
unsigned long task;
unsigned int trimer;
unsigned char fnd[8];
unsigned char mfnd[8];
unsigned int int_state;
unsigned char fnd_state;
unsigned char boat;
bit hold;
//
//
void _interrupt IVN_TIMER1 time_base() {
//////////////////////////////////////////////
_tl1 = 0x60; _th1 = 0xF0; // 4000 2 M Sec 500 Times
//////////////////////////////////////////////
_p0 = 0xff;
_p2 = segment_select[fnd_state];
_p0 = fnd[fnd_state++];
fnd_state &= 0x07;
//////////////////////////////////////////////
if(int_state == 0) { //
P35_o_74f161_enp = 0; //外部计数器F161计数禁止
P30_io_74hc393_clr_hold = 1; //外部计数器HC393复位
P36_o_74f161_clr_n = 0; //外部计数器F161复位
_tl0 = 0x00; _th0 = 0x00; //内部计数器复位
hold = P30_io_74hc393_clr_hold; //  HOLD(保持)键状态输入
P36_o_74f161_clr_n = 1; // 外部计数器F161有效(Enable)
P30_io_74hc393_clr_hold = 0; //  外部计数器HC393有效(Enable)
P35_o_74f161_enp = 1; //  外部计数器F161进行计数
}
//////////////////////////////////////////////
if(int_state == 316) { //  10GHz状态(64分频的预分频器)
if (!P37_i_prescaler) { //  门控时间为0.64秒
for (trimer = 0; trimer<202; trimer++) ; //  15个机器周期单位
// 测试信号24MHz输入
boat++; // 15360000 用于显示,需调整
boat++; //  延迟1个机器周期(12个时钟周期)
boat++; // 15359988
boat++; // 15360000
// boat++; // 15360012
P35_o_74f161_enp = 0; //  外部计数器停止
trailer = _th0;
trailer = (trailer << 20) & 0x0ff00000;
task = _tl0;
task = (task << 12) & 0x000ff000;
trailer |= task;
task = _p3;
task = (task << 7) & 0x00000f00;
trailer |= task;
task = _p1 & 0x000000ff;
trailer |= task;
P35_o_74f161_enp = 1; // ?? ??? ???? ?????
// 电流消耗,
// 外部计数器将重新开始。
}
}
//////////////////////////////////////////////
if(int_state == 494) { // 100 MHz Mode 1 Sec Gate Time
if (P37_i_prescaler) { // 1 Sec Gate Time
for (trimer = 0; trimer<248; trimer++) ; //  15个机器周期单位
// 测试24MHz信号源输入
boat++; // 24000000 用于显示,需调整
boat++; //
boat++; //
boat++; //
boat++; //  延迟1个机器周期(12个时钟周期)
boat++; // 23999988
boat++; // 24000000
// boat++; // 24000012

P35_o_74f161_enp = 0; // 外部计数器停止
trailer = _th0;
trailer = (trailer << 20) & 0x0ff00000;
task = _tl0;
task = (task << 12) & 0x000ff000;
trailer |= task;
task = _p3;
task = (task << 7) & 0x00000f00;
trailer |= task;
task = _p1 & 0x000000ff;
trailer |= task;
P35_o_74f161_enp = 1; // ?? ??? ???? ?????
// 电流消耗,以时间表
// 外部计数器重新开始。
}
}
//////////////////////////////////////////////
if(int_state == 506) { //  1Hz数字显示
boat = trailer % 10;
mfnd[7] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 507) {
boat = trailer % 10;
mfnd[6] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 508) {
boat = trailer % 10;
mfnd[5] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 509) {
boat = trailer % 10;
mfnd[4] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 510) {
boat = trailer % 10;
mfnd[3] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 511) {
boat = trailer % 10;
mfnd[2] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 512) {
boat = trailer % 10;
mfnd[1] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
if(int_state == 513) {
boat = trailer % 10;
mfnd[0] = segment_pattern[boat & 0xf];
trailer /= 10;
}
//////////////////////////////////////////////
int_state++;
//////////////////////////////////////////////
if(int_state >= 514) {
int_state = 0;
if (hold) {
fnd[0] = mfnd[0];
fnd[1] = mfnd[1];
fnd[2] = mfnd[2];
fnd[3] = mfnd[3];
fnd[4] = mfnd[4];
fnd[5] = mfnd[5];
fnd[6] = mfnd[6];
fnd[7] = mfnd[7];
if (P37_i_prescaler) {
fnd[1] &= 0x7F; // MHz点
} else {
fnd[0] &= 0x7F; // GHz点
}
}
}
//////////////////////////////////////////////
}
main()
{
_tmod = 0x15; // 0b00010101 Timer0 = Mode1, Counter, use TR0
// Timer1 = Mode1, Timer, use TR1
_tl0 = 0X0; _th0 = 0X0;
_tl1 = 0X0; _th1 = 0X0;
_tr0 = 1; // Timer 0 计数开始
_tr1 = 1; // Timer 1 计数开始
_et1 = 1; // 设置定时器1中断状态
_ea = 1; //    设置全局中断状态
while(1) ;
}


C程序报错,编译不通过提示:

Build target 'Target 1'

Text3.c(3): warning C318: can't open file 'sfr.h'
Text3.c(4): warning C318: can't open file 'os.h'
TEXT3.C(7): error C129: missing ';' before 'P36_o_74f161_clr_n'
Target not created


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享分享 支持支持 反对反对
沙发
发表于 2023-4-24 18:35:29 | 只看该作者
前两个错误的包含文件没找到,重新指定路径对就可以过了
板凳
 楼主| 发表于 2023-4-25 08:24:04 | 只看该作者
头文件有的.  网上找得到的

头文件.rar

1.51 KB, 下载次数: 0, 下载积分: 银子 -10 两

地板
发表于 2023-5-4 12:56:06 来自手机 | 只看该作者
学习一下,谢谢分享
5#
发表于 2023-5-6 08:30:40 | 只看该作者
学习一下,谢谢分享
6#
发表于 2023-5-8 13:07:19 | 只看该作者
学习一下,谢谢分享
7#
发表于 2023-5-12 13:41:10 | 只看该作者
本帖最后由 afeng114 于 2023-5-16 15:30 编辑

引用的头文件路径不对哦
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|文字版|手机版|DIY编程器网 ( 桂ICP备14005565号-1 )

GMT+8, 2024-4-25 21:57 , 耗时 0.095305 秒, 20 个查询请求 , Gzip 开启.

各位嘉宾言论仅代表个人观点,非属DIY编程器网立场。

桂公网安备 45031202000115号

DIY编程器群(超员):41210778 DIY编程器

DIY编程器群1(满员):3044634 DIY编程器1

diy编程器群2:551025008 diy编程器群2

QQ:28000622;Email:libyoufer@sina.com

本站由桂林市临桂区技兴电子商务经营部独家赞助。旨在技术交流,请自觉遵守国家法律法规,一旦发现将做封号删号处理。

快速回复 返回顶部 返回列表