编写程序
主函数
- #include "HT66F2390.h"
- #include "delay.h"
- #include "uart.h"
- #include "LED.h"
- #include "string.h" //调用strlen函数要引入字符串的头文件
- void main()
- {
- int t=0,i=0; //用于计时
- char date[]="广东工业大学MFT团队合泰单片机串口实验";
- LED_Init(); //LED初始化
- UART_SET(); //串口函数初始化
- while(1)
- {
- GCC_CLRWDT(); //清除看门狗
- delay_ms(10);
- t++;
- if(RECEIVE_Finish_Flag==1)
- {
- if(Rcv_Data[0]==0x01)
- {
- LED1 =!LED1;
- }
- for(i=0;i<RCV_Data_Length;i++)UART_Send_Byte(Rcv_Data[i]);
- RECEIVE_Finish_Flag=0; //清除接收标志位
- }
- if(t==100)
- {
- for(i=0;i<strlen(date);i++)
- {
- UART_Send_Byte(date[i]);
- }
- LED2 =!LED2; //LED2取反用来显示工作是否正常
- t=0;
- }
- GCC_CLRWDT(); //清除看门狗
- }
- }
|