monog 2015-05-20 07:37 采纳率: 0%
浏览 10086

keil编译时 error C141: syntax error near ')'

简单的烟雾报警程序中先是缺少了lcd1602的头文件 我从网上找了添加了后发现有错误 求大神帮我解答一下疑问 谢谢了
/********************************
FILE NAME: lcd1602.c
CHIP TYPE: AT89C51
CLOCK FREQUENCY: 12MHZ
IDE: VSMStudio
COMPILER: IAR for 8051
TIME: September 2010
********************************/

#include "reg52.h"
#include "intrins.h"

// Define P3 pins
#define DATA_BUS (P0)
#define RS (P2_bit.P2_0)
#define RW (P2_bit.P2_1)
#define E (P2_bit.P2_2)

// Define new types
typedef unsigned char uchar;
typedef unsigned int uint;

// Function Prototypes
void check_busy(void);
void write_command(uchar com);
void write_data(uchar data);

void LCD_init(void);
void string(uchar ad ,uchar *s);
void lcd_test(void);
void delay(uint);

void main(void)
{ LCD_init();
while(1)
{ string(0x80,"Have a nice day!");
string(0xC0," Proteus VSM");
delay(100);
write_command(0x01);
delay(100);

}
}

/*******************************************
LCD1602 Driver mapped as IO peripheral
*******************************************/

// Delay
void delay(uint j)
{ uchar i = 60;
for(; j>0; j--)
{ while(--i);
i = 59;
while(--i);
i = 60;
}
}

// Test the Busy bit
void check_busy(void)
{ do
{ DATA_BUS = 0xff;
E = 0;
RS = 0;
RW = 1;
E = 1;
__no_operation();
} while(DATA_BUS & 0x80);
E = 0;
}

// Write a command
void write_command(uchar com)
{ check_busy();
E = 0;
RS = 0;
RW = 0;
DATA_BUS = com;
E = 1;
__no_operation();
E = 0;
delay(1);
}

// Write Data
void write_data(uchar data)
{ check_busy();
E = 0;
RS = 1;
RW = 0;
DATA_BUS = data;
E = 1;
__no_operation();
E = 0;
delay(1);

}

// Initialize LCD controller
void LCD_init(void)
{ write_command(0x38); // 8-bits, 2 lines, 7x5 dots
write_command(0x0C); // no cursor, no blink, enable display
write_command(0x06); // auto-increment on
write_command(0x01); // clear screen
delay(1);
}

// Display a string
void string(uchar ad, uchar *s)
{ write_command(ad);
while(*s>0)
{ write_data(*s++);
delay(100);
}
}

  • 写回答

6条回答 默认 最新

  • donwmufromdying 2015-05-20 08:21
    关注

    给你个简单的笨办法查找定位错误:用宏定义ifdef 把代码分块后每次编译部分代码,看看是哪部份代码引起的错误,逐步缩小范围

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器