stc89c52在keil中用C编程,写入 P1=0; 后程序运行结果就有错误,去掉P1=0;后就正常了,为什么?

日期:2021-06-14 06:15:30 人气:1

stc89c52在keil中用C编程,写入 P1=0; 后程序运行结果就有错误,去掉P1=0;后就正常了,为什么?

void main()
{
init_source();
speed_set(0,7);
}
这种写法会让单片机反复执行这两句,也就是会不断的初始化.
建议写成这种结构
void main()
{
初始化代码();
while(1)
{
speed_set(0,7);
}
}
PS:P1 = 0;写法是正确的.
    A+
热门评论