关于c51单片机的一个问题
新手小白一只这是我写的程序帮忙看看怎么错了#include<reg52.h>#include<intrins.h>//调用循环函数#defineucharunsigned...
新手小白一只 这是我写的程序 帮忙看看怎么错了
#include <reg52.h>
#include <intrins.h> //调用循环函数
#define uchar unsigned char //宏定义 用unchar代替unsigned char
#define uint unsigned int
uint a ;
uchar i;
unsigned temp; //定义循环函数变量
void time(uint z); //延时函数声明
void main()
{
while(1)
{
disP();
//
}
}
unsigned char swt_disp = 0, disp_num = 0;
void disP(void)
{
switch(swt_disp)
{
case 0: //初始化
temp=0xfe;
P1=temp;
timer_1ms = 0;
disp_num = 0;
swt_disp = 1;
break;
case 1: //等待时间
if(timer_1ms >= 1000)
{
swt_disp = 2;
}
break;
case 2:
temp=_crol_(temp,1); //循环左移
P1=temp;
disp_num++;
if(disp_num >= 8)
swt_disp = 0;
else
{
timer_1ms = 0;
swt_disp = 1;
}
break;
}
if(timer_1ms >= 1000)
{
i++;
timer_1ms = 0;
temp=_crol_(temp,1); //循环左移
P1=temp;
}
if(i >= 8)
{
i = 0;
temp=0xfe;
P1=temp;
}
}
unsigned int timer_1ms = 0;
#progra
void timer0_int()
{
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
if(timer_1ms < 65535) timer_1ms++;
}
void time(uint z) //延时函数
{
TMOD=0x01;//定时器0 方式1
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
TR0=1;//启动定时器 】
while(--z)
{
TF0=0;
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
}
}
compiling main.c...
MAIN.C(14): warning C206: 'disP': missing function-prototype
错误
MAIN.C(22): error C231: 'disP': redefinition
MAIN.C(28): error C202: 'timer_1ms': undefined identifier
MAIN.C(33): error C202: 'timer_1ms': undefined identifier 展开
#include <reg52.h>
#include <intrins.h> //调用循环函数
#define uchar unsigned char //宏定义 用unchar代替unsigned char
#define uint unsigned int
uint a ;
uchar i;
unsigned temp; //定义循环函数变量
void time(uint z); //延时函数声明
void main()
{
while(1)
{
disP();
//
}
}
unsigned char swt_disp = 0, disp_num = 0;
void disP(void)
{
switch(swt_disp)
{
case 0: //初始化
temp=0xfe;
P1=temp;
timer_1ms = 0;
disp_num = 0;
swt_disp = 1;
break;
case 1: //等待时间
if(timer_1ms >= 1000)
{
swt_disp = 2;
}
break;
case 2:
temp=_crol_(temp,1); //循环左移
P1=temp;
disp_num++;
if(disp_num >= 8)
swt_disp = 0;
else
{
timer_1ms = 0;
swt_disp = 1;
}
break;
}
if(timer_1ms >= 1000)
{
i++;
timer_1ms = 0;
temp=_crol_(temp,1); //循环左移
P1=temp;
}
if(i >= 8)
{
i = 0;
temp=0xfe;
P1=temp;
}
}
unsigned int timer_1ms = 0;
#progra
void timer0_int()
{
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
if(timer_1ms < 65535) timer_1ms++;
}
void time(uint z) //延时函数
{
TMOD=0x01;//定时器0 方式1
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
TR0=1;//启动定时器 】
while(--z)
{
TF0=0;
TH0=(65536-50000)/256;//延时
TL0=(65536-50000)%256;
}
}
compiling main.c...
MAIN.C(14): warning C206: 'disP': missing function-prototype
错误
MAIN.C(22): error C231: 'disP': redefinition
MAIN.C(28): error C202: 'timer_1ms': undefined identifier
MAIN.C(33): error C202: 'timer_1ms': undefined identifier 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询