没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
#include<p18f452.h>
#include <delays.h>
#define RSPIN PORTBbits.RB5 //Data or Instrument Select
#define RWPIN PORTBbits.RB4 //Write or Read
#define EPIN PORTBbits.RB3 //6800 mode Enable single
#define INPUT PORTBbits.RB2
#define cold PORTBbits.RB6
#define warm PORTBbits.RB7
#define STS PORTAbits.RA0
#define CS PORTAbits.RA1
#define A0 PORTAbits.RA2
#define CE PORTAbits.RA3
#define RC PORTAbits.RA4
void InterruptHandlerHigh (void);
#define uchar unsigned char//宏定义
#define uint unsigned int
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
K_UP 0X20//定义键值
0X21
0X25
0X30
0X31
0X32
0X33
0X34
0X43
0X36
0X38
0X37
0X40
0X41
0X42
K_DOWN
K_OK
K_CLEAR 0X24
K_ONE
K_FOUR
K_SEVEN
K_POINT
K_TWO
K_FIVE
K_EIGHT
K_ZERO
K_THREE
K_SIX
K_NINE
K_SET
#include"key.h"
////////////////////全局变量/////////////////////////////
unsigned int Timeout;
float TEMP_NOW=0.0;
float TEMP_SET=21.0;
uint T_Count=0;
uint S_Count=0;
uint P_Count=0;
uint N_Count=0;
uint M_Count=1;
uchar Current_Temp_Display_Buffer[]={" NOW:-23.5 "};
uchar set_Temp_Display_Buffer[]= {" SET: 21.0 "};
int sel=0;
void Comparison();
//////////////////////定时///////////////////////////////
void timer0_init(void)
{
Timeout = 0;
INTCON = 0x20; //disable global and enable TMR0
interrupt
INTCON2 = 0x84; //TMR0 high priority
RCONbits.IPEN = 1; //enable priority levels
TMR0H = 0; //clear timer
TMR0L = 0; //clear timer
T0CON = 0x82; //set up timer0 - prescaler 1:8
INTCONbits.GIEH = 1; //enable interrupts
TRISD = 0; /* configure PORTD for output */
PORTD=0X00;
if (Timeout == 1)
{ //timeout?
Timeout = 0; //clear timeout indicor
Read_Temperature();
Display_Temperature() ;
N_Count=1;
}
}
// High priority interrupt vector
//PIC 中断标准服务程序
#pragma code InterruptVectorHigh = 0x08 //中断向量
void
InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
//-------------------------------------------------------------------
---------
// High priority interrupt routine
//中断服务程序
#pragma code
#pragma interrupt InterruptHandlerHigh
void
InterruptHandlerHigh ()
{
if (INTCONbits.TMR0IF)
{ //check for TMR0 overflow
INTCONbits.TMR0IF = 0; //clear interrupt flag
Timeout = 1; //indicate timeout
}
}
void Comparison()
{
if(N_Count&&M_Count)
{
if(TEMP_NOW<TEMP_SET)
{
}
if(TEMP_NOW>TEMP_SET)
{
}
if(TEMP_NOW==TEMP_SET)
{
cold=1;
warm=0;
warm=1;
cold=0;
}
}
}
cold=0;
warm=0;
uchar int_LM20();
void Read_Temperature();
void Display_Temperature();
void ad_convertor()
{
float temp;
OpenADC( ADC_FOSC_32 &
ADC_RIGHT_JUST &
ADC_8ANA_0REF,
ADC_RA0 &
ADC_INT_OFF );
// A/D 时钟源,晶振 32 分频率
// A/D 转换结果右对齐
// A/D 参考电压源,电源工作电压
// 通道选择
// 中断关闭,查询模式
Delay10TCYx( 5 ); // Delay for 50TCY
ConvertADC(); // Start conversion
while( BusyADC() ); // Wait for completion
temp = ReadADC(); // Read result
CloseADC(); // Disable A/D converter
Nop();
Temp_Value[0]=temp/256;
Temp_Value[1]=temp%256;
}
void Display_Temperature()
{
uchar t = 150, ng = 0;
if((Temp_Value[1]&0xf8)==0xf8)
{
Temp_Value[1] = ~Temp_Value[1];
Temp_Value[0] = ~Temp_Value[0]+1;
if(Temp_Value[0]==0x00)
}
Temp_Value[1]++;
ng = 1;
Display_Digit[0] = df_Table[Temp_Value[0]&0x0f];
CurrentT = ((Temp_Value[0]&0xf0)>>4) | ((Temp_Value[1]&0x07)<<4);
Display_Digit[3] = CurrentT/100;
Display_Digit[2] = CurrentT%100/10;
Display_Digit[1] = CurrentT%10;
Current_Temp_Display_Buffer[11] = Display_Digit[0] + '0';
Current_Temp_Display_Buffer[10] = '.';
Current_Temp_Display_Buffer[9] = Display_Digit[1] + '0';
Current_Temp_Display_Buffer[8] = Display_Digit[2] + '0';
Current_Temp_Display_Buffer[7] = Display_Digit[3] + '0';
TEMP_NOW=Display_Digit[2]*10+Display_Digit[1]+Display_Digit[0]*0.
1 ;
if(Display_Digit[3] == 0)
{
TEMP_NOW=-(Display_Digit[2]*10+Display_Digit[1]+Display_Digit[0]*
Current_Temp_Display_Buffer[7] = ' ';
Current_Temp_Display_Buffer[8] = ' ';
if(Display_Digit[2] == 0&&Display_Digit[3]==0)
if(ng)
0.1);
if(Current_Temp_Display_Buffer[8] == ' ')
Current_Temp_Display_Buffer[8] = '-';
Current_Temp_Display_Buffer[7] = '-';
Current_Temp_Display_Buffer[6] = '-';
else if(Current_Temp_Display_Buffer[7] == ' ')
else
}
剩余28页未读,继续阅读
资源评论
a66889999
- 粉丝: 39
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功