开发环境:windows xp + MDK v4.71a
调试工具:ULink 2
芯片PC 1788
库版本:v1.17
程序功能:通过串口0发送数据给LCD 1602显示,接收到“clear”时清屏,接收到两个连续的空格时换行。波特率9600,数据位8位,停止位1位,奇校验。
串口助手:Teminal
存在问题可能标题没说得很明白,单步调试时上述功能正常,全速运行时接收到"clear "和空格时不执行相关功能,而是显示"clear "和空格。
下面是主函数的程序- uint8_t clear[] = "clear";
- uint8_t linefeed[] = " ";
- int main(void)
- {
- uint8_t disp[24];
- uint8_t i = 1,k = 1;
- LCD1602_GPIO_Init();
- LCD1602_Init();
- UARTn_Init();
- UARTSend(_LPC_UART, menu, sizeof(menu));
- while (1)
- {
- if (receiveok == SET)
- {
- receiveok = RESET;
- UARTReceive(_LPC_UART, disp, sizeof(disp));
- i = strcmp((const char *)disp, (const char *)clear);
- k = strcmp((const char *)disp, (const char *)linefeed);
- if (0 == k)
- {
- Cousor_Y = 1 - Cousor_Y;
- Cousor_X = 0;
- }
- else if (0 == i)
- {
- LCD1602_DisplayClear();
- Cousor_X = 0;
- Cousor_Y = 0;
- }
- else
- {
- LCD1602_SetCousor(Cousor_X, Cousor_Y);
- LCD1602_DisplayString(disp);
- }
- memset(disp, 0, sizeof(disp));
- }
- }
- }
|