/////////////////////////////////////
// Config2 Code Configuration File //
/////////////////////////////////////
#include "c8051f310.h"
// Peripheral specific initialization functions,
// Called from the Init_Device() function
sbit JR1 = P1^4; //定义控制端口
sbit JR2 = P1^5;
sbit FAN = P1^6;
void Port_IO_Init()
{
// P0.0 - Unassigned, Open-Drain, Digital
// P0.1 - Unassigned, Open-Drain, Digital
// P0.2 - Unassigned, Open-Drain, Digital
// P0.3 - Unassigned, Open-Drain, Digital
// P0.4 - Unassigned, Open-Drain, Digital
// P0.5 - Unassigned, Open-Drain, Digital
// P0.6 - Unassigned, Open-Drain, Digital
// P0.7 - Unassigned, Open-Drain, Digital
// P1.0 - Skipped, Open-Drain, Analog
// P1.1 - Skipped, Open-Drain, Analog
// P1.2 - Skipped, Open-Drain, Analog
// P1.3 - Skipped, Open-Drain, Analog
// P1.4 - Unassigned, Open-Drain, Digital
// P1.5 - Unassigned, Open-Drain, Digital
// P1.6 - Unassigned, Open-Drain, Digital
// P1.7 - Unassigned, Open-Drain, Digital
// P2.0 - Unassigned, Open-Drain, Digital
// P2.1 - Unassigned, Open-Drain, Digital
// P2.2 - Unassigned, Open-Drain, Digital
// P2.3 - Unassigned, Open-Drain, Digital
P1MDIN = 0xF0;
//P1MDOUT = 0x0F;
P1SKIP = 0x0F;
XBR1 = 0x40;
}
void Comparator_Init()
{
int i;
CPT0CN = 0x80;
for (i = 0; i < 35; i++); // Wait 10us for initialization
CPT0CN &= ~0x30;
CPT1CN = 0x80;
for (i = 0; i < 35; i++); // Wait 10us for initialization
CPT1CN &= ~0x30;
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
Port_IO_Init();
Comparator_Init();
}
void main()
{
Init_Device();//初始化C8051F310
JR1=0;//初始化控制端口
JR2=0;//初始化控制端口
FAN=0;//初始化控制端口
while(1)
{
if(CPT0CN/0xc0<=0)//如果温度小于0度
{
JR1=1;
JR2=1;//给加热膜通电加热
}
else
{
JR1=0;
JR2=0;//给加热膜断电
}
//---------------------------------------
if(CPT1CN/0xc0>=1)//如果温度大于30度
{
FAN=1;//散热风扇转动
}
else
{
FAN=0;//散热风扇停转
}
}
}
tc1.rar_8051F3_C8051F310
版权申诉
170 浏览量
2022-09-20
14:41:00
上传
评论
收藏 1KB RAR 举报
Kinonoyomeo
- 粉丝: 74
- 资源: 1万+
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈