找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 2665|回復(fù): 8
打印 上一主題 下一主題
收起左側(cè)

STC 15F101W編譯出現(xiàn)警告,可否指點(diǎn)一下

[復(fù)制鏈接]
回帖獎勵 20 黑幣 回復(fù)本帖可獲得 20 黑幣獎勵! 每人限 1 次
跳轉(zhuǎn)到指定樓層
樓主
ID:293757 發(fā)表于 2018-3-19 11:36 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
STC15f101W,keil uvision3編譯時出現(xiàn)0錯誤,3警告。希望哪位能指導(dǎo)一點(diǎn)方向,本人在軟件方面有點(diǎn)菜。
/******************************************/
#include "stc15f2k.h"
#include <intrins.h>
#define  MAIN_Fosc     22118400L   //定義主時鐘
#define  uchar unsigned char
/*************  本地聲明  **************/
sbit AC_Fail=P3^2;
sbit Iout_rev=P3^3;
sbit Out=P3^4;        
sbit Onoff=P3^5;        
bit Operated_flag;
bit Soft_shutdown_state;
bit sys_no_output;
bit Ups_operating_flag;
uchar aa=0;
void onoff_sw_ensure();
void initial();
void delay_ms(uchar bb);
void soft_shutdown_detect();
void operated_detect();
void turn_off();
void restart();
/********************** initial ************************/
void intial(){
P3M1=0;     //設(shè)置P3^2,^3,^5輸入
P3M0=0x10;     //設(shè)置P3^4輸出
Out=1;Soft_shutdown_state=0;sys_no_output=0;
Ups_operating_flag=0; Operated_flag=0;}
//**onoff ensure**//
void onoff_sw_ensure(){
if((Onoff==0)&&(Iout_rev==1)&&(Out==0))
Out=1;}
//**operated detect**//
void operated_detect(){
if((Onoff==1)&&(Iout_rev==0)&&(Operated_flag==0)){
aa++;
if(aa==100){
aa=0;
Operated_flag=1;}}}
/********************** soft_shutdown_detect************************/
void soft_shutdown_detect(){
if((Operated_flag==1)&&(Iout_rev==1)&&(Onoff==1)){
Soft_shutdown_state=1;
Operated_flag=0;}}
/********************** main ************************/
void main(){
initial();
delay_ms(1);
while(1){
onoff_sw_ensure();
operated_detect();
soft_shutdown_detect();
turn_off();
restart();}}
/********************** restart ************************/
void restart(){
if((sys_no_output==1)&&(AC_Fail==0)){
Out=1;
sys_no_output=0;
}}
/********************** turnoff ************************/
void turn_off(){
if((Soft_shutdown_state==1)&&(AC_Fail==1)&&(Onoff==1)){
Out=0; sys_no_output=1;
Soft_shutdown_state=0;};
if((Operated_flag==1)&&(AC_Fail==1)&&(Onoff==1)&&(Iout_rev==0))
{Ups_operating_flag=1;};
if((Ups_operating_flag==1)&&(Iout_rev==1)){
sys_no_output=1; Ups_operating_flag=0;Operated_flag=0;}}
/********************** delay ************************/
void delay_ms(uchar bb){
uchar cc;
for(;bb>0;bb--){for(cc=0;cc<122; cc++);}}

評分

參與人數(shù) 1黑幣 +8 收起 理由
JACKLI + 8 贊一個!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:67356 發(fā)表于 2018-3-19 21:51 | 只看該作者
/******************************************/
#include "stc15f2k.h"
#include <intrins.h>
#define  MAIN_Fosc     22118400L   //定義主時鐘
#define  uchar unsigned char
/*************  本地聲明  **************/
sbit AC_Fail=P3^2;
sbit Iout_rev=P3^3;
sbit Out=P3^4;
sbit Onoff=P3^5;
bit Operated_flag;
bit Soft_shutdown_state;
bit sys_no_output;
bit Ups_operating_flag;
uchar aa=0;
void onoff_sw_ensure();
void initial();
void delay_ms(uchar bb);
void soft_shutdown_detect();
void operated_detect();
void turn_off();
void restart();
/********************** initial ************************/
void intial() //這里名字弄錯了,改成initial
{
    P3M1=0;     //設(shè)置P3^2,^3,^5輸入
    P3M0=0x10;     //設(shè)置P3^4輸出
    Out=1;
    Soft_shutdown_state=0;
    sys_no_output=0;
    Ups_operating_flag=0;
    Operated_flag=0;
}
//**onoff ensure**//
void onoff_sw_ensure()
{
    if((Onoff==0)&&(Iout_rev==1)&&(Out==0))
    {
        Out=1;
    }
}
//**operated detect**//
void operated_detect()
{
    if((Onoff==1)&&(Iout_rev==0)&&(Operated_flag==0))
    {
        aa++;
        if(aa==100)
        {
            aa=0;
            Operated_flag=1;
        }
    }
}
/********************** soft_shutdown_detect************************/
void soft_shutdown_detect()
{
    if((Operated_flag==1)&&(Iout_rev==1)&&(Onoff==1))
    {
        Soft_shutdown_state=1;
        Operated_flag=0;
    }
}
/********************** main ************************/
void main()
{
    initial();
    delay_ms(1);
    while(1)
    {
        onoff_sw_ensure();
        operated_detect();
        soft_shutdown_detect();
        turn_off();
        restart();
    }
}
/********************** restart ************************/
void restart()
{
    if((sys_no_output==1)&&(AC_Fail==0))
    {
        Out=1;
        sys_no_output=0;
    }
}
/********************** turnoff ************************/
void turn_off()
{
    if((Soft_shutdown_state==1)&&(AC_Fail==1)&&(Onoff==1))
    {
        Out=0;
        sys_no_output=1;
        Soft_shutdown_state=0;
    };
    if((Operated_flag==1)&&(AC_Fail==1)&&(Onoff==1)&&(Iout_rev==0))
    {
        Ups_operating_flag=1;
    };
    if((Ups_operating_flag==1)&&(Iout_rev==1))
    {
        sys_no_output=1;
        Ups_operating_flag=0;
        Operated_flag=0;
    }
}
/********************** delay ************************/
void delay_ms(uchar bb)
{
    uchar cc;
    for(; bb>0; bb--)
    {
        for(cc=0; cc<122; cc++)
        {
            ;
        }
    }
}

評分

參與人數(shù) 1黑幣 +40 收起 理由
admin + 40 回帖助人的獎勵!

查看全部評分

回復(fù)

使用道具 舉報

板凳
ID:164602 發(fā)表于 2018-3-20 08:22 | 只看該作者
就是這條語句:
void intial() //這里名字弄錯了,改成initial
改了就好了。
回復(fù)

使用道具 舉報

地板
ID:96072 發(fā)表于 2018-3-23 15:07 | 只看該作者
void intial() //這里名字弄錯了,改成initial
回復(fù)

使用道具 舉報

5#
ID:296086 發(fā)表于 2018-3-23 18:59 | 只看該作者
有錯誤信息嗎
回復(fù)

使用道具 舉報

6#
ID:296086 發(fā)表于 2018-3-23 19:00 | 只看該作者
void intial() //這里名字弄錯了,改成initial
回復(fù)

使用道具 舉報

7#
ID:223788 發(fā)表于 2018-3-24 16:46 | 只看該作者

void intial()  名字錯了,改成initial

一般警告可以不用理會,不會影響代碼與實(shí)際效果
回復(fù)

使用道具 舉報

8#
ID:293757 發(fā)表于 2018-3-26 09:06 | 只看該作者
謝謝各位,本來發(fā)布后沒有看到回復(fù),感到心灰,覺得不用關(guān)注這個網(wǎng)站了。還是有很多熱心的同仁啊,
回復(fù)

使用道具 舉報

9#
ID:295783 發(fā)表于 2018-3-26 10:57 | 只看該作者
沒有錯誤信息不用管 有報警沒關(guān)系 直接燒錄就好了
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表