📄 main.c
字号:
/*========================================================/
/ /
/ Copyright (C), 2001-2005, Pangu Automation. Co., Ltd. /
/ FileName: main.c /
/ Author: Zheng M.D. /
/ Version: 1.0 /
/ Date: 2005.11.12 /
/ Description: 酸度计(pH计)AD板主程序 /
/ Modify: /
/ /
/========================================================*/
#include <reg52.h>
#include "include/CS5529.h"
#include "include/time.h"
#include "include/serialcom.h"
#include "include/DAC7612.h"
#include "include/X5045.h"
#include "include/DataProces.h"
unsigned char idata channel=0; // 0:pH,1:pt1000 G,2:pt1000 D,3:Gnd,4:mA
/*************************************************
//函 数 名:SysIni()
//功 能:初始化系统,及系统内设备
//输入参数:无
//返 回 值:无
//备 注:
*************************************************/
void SysIni()
{
__All_Int_Disable(); //关闭所有中断
__Serial_Highest(); //设置串口中断为最高级别
__Serial_Uart8(); // n,8,1
InitUart0();
__Int_Enable(); //中断使能
__Uart_Enable(); //串口中断使能
__Uart_Rec_Enable();
InitTimer2();
}
/*******************************************************************
主程序
*******************************************************************/
void main()
{
X5045_Stop(); //停止看门,以下初始化可能要花若干秒时间
//FlashLed(20);
SysIni(); //系统初始化 CS5529_Init(); //CS5529初始化
//
SelectSignalAndGain(1); //初始化通道和增益
GetCaliParam(); //取标定参数
FlashLed(20); //闪闪闪,说明程序在初始化
X5045_Start(); //启用看门狗
while(1)
{
if(GetTimer2Flg() == 1) //时间定时到
{
ClrTimer2Flg(); //清除定时标记
ProcessADInput(channel); //AD输入
// ProcessDAOutput();
channel++;
if(channel>4){
channel=0; //一个任务周期到
ResetWDT(); //喂狗
__RUN = ~__RUN; //一闪一闪亮晶晶 说明程序在执行
ProcessDAOutput(); //DA输出
}
}
SaveCaliParam(); //如果要保存标定数据,则保存
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -